agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH v15] Avoid orphaned objects dependencies 249+ messages / 2 participants [nested] [flat]
* [PATCH v15] Avoid orphaned objects dependencies @ 2024-03-29 15:43 Bertrand Drouvot <bertranddrouvot.pg@gmail.com> 0 siblings, 0 replies; 249+ messages in thread From: Bertrand Drouvot @ 2024-03-29 15:43 UTC (permalink / raw) It's currently possible to create orphaned objects dependencies, for example: Scenario 1: session 1: begin; drop schema schem; session 2: create a function in the schema schem session 1: commit; With the above, the function created in session 2 would be linked to a non existing schema. Scenario 2: session 1: begin; create a function in the schema schem session 2: drop schema schem; session 1: commit; With the above, the function created in session 1 would be linked to a non existing schema. To avoid those scenarios, a new lock (that conflicts with a lock taken by DROP) has been put in place before the dependencies are being recorded. With this in place, the drop schema in scenario 2 would be locked. Also, after the new lock attempt, the patch checks that the object still exists: with this in place session 2 in scenario 1 would be locked and would report an error once session 1 committs (that would not be the case should session 1 abort the transaction). If the object is dropped before the new lock attempt is triggered then the patch would also report an error (but with less details). The patch takes into account any type of objects except the ones that are pinned (they are not droppable because the system requires it). A special case is done for objects that belong to the RelationRelationId class. For those, we should be in one of the two following cases that would already prevent the relation to be dropped: 1. The relation is already locked (could be an existing relation or a relation that we are creating). 2. The relation is protected indirectly (i.e an index protected by a lock on its table, a table protected by a lock on a function that depends the table...) To avoid any risks for the RelationRelationId class case, we acquire a lock if there is none. That may add unnecessary lock for 2. but that's worth it. The patch adds a few tests for some dependency cases (that would currently produce orphaned objects): - schema and function (as the above scenarios) - alter a dependency (function and schema) - function and arg type - function and return type - function and function - domain and domain - table and type - server and foreign data wrapper --- src/backend/catalog/aclchk.c | 1 + src/backend/catalog/dependency.c | 212 ++++++++++++++++++ src/backend/catalog/heap.c | 7 + src/backend/catalog/index.c | 26 +++ src/backend/catalog/objectaddress.c | 57 +++++ src/backend/catalog/pg_aggregate.c | 9 + src/backend/catalog/pg_attrdef.c | 1 + src/backend/catalog/pg_cast.c | 5 + src/backend/catalog/pg_collation.c | 1 + src/backend/catalog/pg_constraint.c | 26 +++ src/backend/catalog/pg_conversion.c | 2 + src/backend/catalog/pg_depend.c | 40 +++- src/backend/catalog/pg_operator.c | 19 ++ src/backend/catalog/pg_proc.c | 17 +- src/backend/catalog/pg_publication.c | 7 + src/backend/catalog/pg_range.c | 6 + src/backend/catalog/pg_type.c | 39 ++++ src/backend/catalog/toasting.c | 1 + src/backend/commands/alter.c | 4 + src/backend/commands/amcmds.c | 1 + src/backend/commands/cluster.c | 7 + src/backend/commands/event_trigger.c | 1 + src/backend/commands/extension.c | 5 + src/backend/commands/foreigncmds.c | 7 + src/backend/commands/functioncmds.c | 6 + src/backend/commands/indexcmds.c | 2 + src/backend/commands/opclasscmds.c | 18 ++ src/backend/commands/operatorcmds.c | 30 +++ src/backend/commands/policy.c | 2 + src/backend/commands/proclang.c | 3 + src/backend/commands/sequence.c | 2 + src/backend/commands/statscmds.c | 10 + src/backend/commands/tablecmds.c | 34 ++- src/backend/commands/trigger.c | 29 ++- src/backend/commands/tsearchcmds.c | 73 +++++- src/backend/commands/typecmds.c | 84 +++++++ src/backend/rewrite/rewriteDefine.c | 1 + src/backend/utils/errcodes.txt | 1 + src/include/catalog/dependency.h | 3 + src/include/catalog/objectaddress.h | 1 + .../expected/test_dependencies_locks.out | 129 +++++++++++ src/test/isolation/isolation_schedule | 1 + .../specs/test_dependencies_locks.spec | 89 ++++++++ .../test_oat_hooks/expected/alter_table.out | 4 +- .../expected/test_oat_hooks.out | 2 + src/test/regress/expected/alter_table.out | 11 +- 46 files changed, 1011 insertions(+), 25 deletions(-) 39.6% src/backend/catalog/ 30.5% src/backend/commands/ 16.7% src/test/isolation/expected/ 10.4% src/test/isolation/specs/ diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index a44ccee3b6..9a24872a30 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -1413,6 +1413,7 @@ SetDefaultACL(InternalDefaultACL *iacls) referenced.objectId = iacls->nspid; referenced.objectSubId = 0; + LockNotPinnedObject(NamespaceRelationId, iacls->nspid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); } } diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index 0489cbabcb..a3770d7206 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -1519,6 +1519,81 @@ AcquireDeletionLock(const ObjectAddress *object, int flags) } } +/* + * LockNotPinnedObjectById + * + * Lock the object that we are about to record a dependency on. + * After it's locked, verify that it hasn't been dropped while we + * weren't looking. If the object has been dropped, this function + * does not return! + */ +void +LockNotPinnedObjectById(const ObjectAddress *object) +{ + char *object_description = NULL; + + if (isObjectPinned(object)) + return; + + object_description = getObjectDescription(object, true); + + if (object->classId == RelationRelationId) + { + Assert(!IsSharedRelation(object->objectId)); + + /* + * We must be in one of the two following cases that would already + * prevent the relation to be dropped: 1. The relation is already + * locked (could be an existing relation or a relation that we are + * creating). 2. The relation is protected indirectly (i.e an index + * protected by a lock on its table, a table protected by a lock on a + * function that depends of the table...). To avoid any risks, acquire + * a lock if there is none. That may add unnecessary lock for 2. but + * that's worth it. + */ + if (!CheckRelationOidLockedByMe(object->objectId, AccessShareLock, true)) + LockRelationOid(object->objectId, AccessShareLock); + } + else + { + /* assume we should lock the whole object not a sub-object */ + LockDatabaseObject(object->classId, object->objectId, 0, AccessShareLock); + } + + /* check if object still exists */ + if (!ObjectByIdExist(object)) + { + if (object_description) + ereport(ERROR, + (errcode(ERRCODE_DEPENDENT_OBJECTS_DOES_NOT_EXIST), + errmsg("%s does not exist", object_description))); + else + ereport(ERROR, + (errcode(ERRCODE_DEPENDENT_OBJECTS_DOES_NOT_EXIST), + errmsg("a dependent object does not exist"))); + } + + if (object_description) + pfree(object_description); + + return; +} + +/* + * LockNotPinnedObject + * + * Lock the object that we are about to record a dependency on. + */ +void +LockNotPinnedObject(Oid classid, Oid objid) +{ + ObjectAddress object; + + ObjectAddressSet(object, classid, objid); + + LockNotPinnedObjectById(&object); +} + /* * ReleaseDeletionLock - release an object deletion lock * @@ -1730,6 +1805,7 @@ find_expr_references_walker(Node *node, if (rte->rtekind == RTE_RELATION) { /* If it's a plain relation, reference this column */ + LockNotPinnedObject(RelationRelationId, rte->relid); add_object_address(RelationRelationId, rte->relid, var->varattno, context->addrs); } @@ -1756,6 +1832,7 @@ find_expr_references_walker(Node *node, Oid objoid; /* A constant must depend on the constant's datatype */ + LockNotPinnedObject(TypeRelationId, con->consttype); add_object_address(TypeRelationId, con->consttype, 0, context->addrs); @@ -1767,8 +1844,11 @@ find_expr_references_walker(Node *node, */ if (OidIsValid(con->constcollid) && con->constcollid != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, con->constcollid); add_object_address(CollationRelationId, con->constcollid, 0, context->addrs); + } /* * If it's a regclass or similar literal referring to an existing @@ -1785,59 +1865,83 @@ find_expr_references_walker(Node *node, objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(PROCOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(ProcedureRelationId, objoid); add_object_address(ProcedureRelationId, objoid, 0, context->addrs); + } break; case REGOPEROID: case REGOPERATOROID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(OPEROID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(OperatorRelationId, objoid); add_object_address(OperatorRelationId, objoid, 0, context->addrs); + } break; case REGCLASSOID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(RELOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(RelationRelationId, objoid); add_object_address(RelationRelationId, objoid, 0, context->addrs); + } break; case REGTYPEOID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(TYPEOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(TypeRelationId, objoid); add_object_address(TypeRelationId, objoid, 0, context->addrs); + } break; case REGCOLLATIONOID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(COLLOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(CollationRelationId, objoid); add_object_address(CollationRelationId, objoid, 0, context->addrs); + } break; case REGCONFIGOID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(TSCONFIGOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(TSConfigRelationId, objoid); add_object_address(TSConfigRelationId, objoid, 0, context->addrs); + } break; case REGDICTIONARYOID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(TSDICTOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(TSDictionaryRelationId, objoid); add_object_address(TSDictionaryRelationId, objoid, 0, context->addrs); + } break; case REGNAMESPACEOID: objoid = DatumGetObjectId(con->constvalue); if (SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(objoid))) + { + LockNotPinnedObject(NamespaceRelationId, objoid); add_object_address(NamespaceRelationId, objoid, 0, context->addrs); + } break; /* @@ -1859,18 +1963,23 @@ find_expr_references_walker(Node *node, Param *param = (Param *) node; /* A parameter must depend on the parameter's datatype */ + LockNotPinnedObject(TypeRelationId, param->paramtype); add_object_address(TypeRelationId, param->paramtype, 0, context->addrs); /* and its collation, just as for Consts */ if (OidIsValid(param->paramcollid) && param->paramcollid != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, param->paramcollid); add_object_address(CollationRelationId, param->paramcollid, 0, context->addrs); + } } else if (IsA(node, FuncExpr)) { FuncExpr *funcexpr = (FuncExpr *) node; + LockNotPinnedObject(ProcedureRelationId, funcexpr->funcid); add_object_address(ProcedureRelationId, funcexpr->funcid, 0, context->addrs); /* fall through to examine arguments */ @@ -1879,6 +1988,7 @@ find_expr_references_walker(Node *node, { OpExpr *opexpr = (OpExpr *) node; + LockNotPinnedObject(OperatorRelationId, opexpr->opno); add_object_address(OperatorRelationId, opexpr->opno, 0, context->addrs); /* fall through to examine arguments */ @@ -1887,6 +1997,7 @@ find_expr_references_walker(Node *node, { DistinctExpr *distinctexpr = (DistinctExpr *) node; + LockNotPinnedObject(OperatorRelationId, distinctexpr->opno); add_object_address(OperatorRelationId, distinctexpr->opno, 0, context->addrs); /* fall through to examine arguments */ @@ -1895,6 +2006,7 @@ find_expr_references_walker(Node *node, { NullIfExpr *nullifexpr = (NullIfExpr *) node; + LockNotPinnedObject(OperatorRelationId, nullifexpr->opno); add_object_address(OperatorRelationId, nullifexpr->opno, 0, context->addrs); /* fall through to examine arguments */ @@ -1903,6 +2015,7 @@ find_expr_references_walker(Node *node, { ScalarArrayOpExpr *opexpr = (ScalarArrayOpExpr *) node; + LockNotPinnedObject(OperatorRelationId, opexpr->opno); add_object_address(OperatorRelationId, opexpr->opno, 0, context->addrs); /* fall through to examine arguments */ @@ -1911,6 +2024,7 @@ find_expr_references_walker(Node *node, { Aggref *aggref = (Aggref *) node; + LockNotPinnedObject(ProcedureRelationId, aggref->aggfnoid); add_object_address(ProcedureRelationId, aggref->aggfnoid, 0, context->addrs); /* fall through to examine arguments */ @@ -1919,6 +2033,7 @@ find_expr_references_walker(Node *node, { WindowFunc *wfunc = (WindowFunc *) node; + LockNotPinnedObject(ProcedureRelationId, wfunc->winfnoid); add_object_address(ProcedureRelationId, wfunc->winfnoid, 0, context->addrs); /* fall through to examine arguments */ @@ -1935,8 +2050,11 @@ find_expr_references_walker(Node *node, */ if (sbsref->refrestype != sbsref->refcontainertype && sbsref->refrestype != sbsref->refelemtype) + { + LockNotPinnedObject(TypeRelationId, sbsref->refrestype); add_object_address(TypeRelationId, sbsref->refrestype, 0, context->addrs); + } /* fall through to examine arguments */ } else if (IsA(node, SubPlan)) @@ -1960,16 +2078,25 @@ find_expr_references_walker(Node *node, * anywhere else in the expression. */ if (OidIsValid(reltype)) + { + LockNotPinnedObject(RelationRelationId, reltype); add_object_address(RelationRelationId, reltype, fselect->fieldnum, context->addrs); + } else + { + LockNotPinnedObject(TypeRelationId, fselect->resulttype); add_object_address(TypeRelationId, fselect->resulttype, 0, context->addrs); + } /* the collation might not be referenced anywhere else, either */ if (OidIsValid(fselect->resultcollid) && fselect->resultcollid != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, fselect->resultcollid); add_object_address(CollationRelationId, fselect->resultcollid, 0, context->addrs); + } } else if (IsA(node, FieldStore)) { @@ -1980,53 +2107,76 @@ find_expr_references_walker(Node *node, if (OidIsValid(reltype)) { ListCell *l; + bool locked = false; foreach(l, fstore->fieldnums) + { + if (!locked) + { + LockNotPinnedObject(RelationRelationId, reltype); + locked = true; + } add_object_address(RelationRelationId, reltype, lfirst_int(l), context->addrs); + } } else + { + LockNotPinnedObject(TypeRelationId, fstore->resulttype); add_object_address(TypeRelationId, fstore->resulttype, 0, context->addrs); + } } else if (IsA(node, RelabelType)) { RelabelType *relab = (RelabelType *) node; /* since there is no function dependency, need to depend on type */ + LockNotPinnedObject(TypeRelationId, relab->resulttype); add_object_address(TypeRelationId, relab->resulttype, 0, context->addrs); /* the collation might not be referenced anywhere else, either */ if (OidIsValid(relab->resultcollid) && relab->resultcollid != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, relab->resultcollid); add_object_address(CollationRelationId, relab->resultcollid, 0, context->addrs); + } } else if (IsA(node, CoerceViaIO)) { CoerceViaIO *iocoerce = (CoerceViaIO *) node; /* since there is no exposed function, need to depend on type */ + LockNotPinnedObject(TypeRelationId, iocoerce->resulttype); add_object_address(TypeRelationId, iocoerce->resulttype, 0, context->addrs); /* the collation might not be referenced anywhere else, either */ if (OidIsValid(iocoerce->resultcollid) && iocoerce->resultcollid != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, iocoerce->resultcollid); add_object_address(CollationRelationId, iocoerce->resultcollid, 0, context->addrs); + } } else if (IsA(node, ArrayCoerceExpr)) { ArrayCoerceExpr *acoerce = (ArrayCoerceExpr *) node; /* as above, depend on type */ + LockNotPinnedObject(TypeRelationId, acoerce->resulttype); add_object_address(TypeRelationId, acoerce->resulttype, 0, context->addrs); /* the collation might not be referenced anywhere else, either */ if (OidIsValid(acoerce->resultcollid) && acoerce->resultcollid != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, acoerce->resultcollid); add_object_address(CollationRelationId, acoerce->resultcollid, 0, context->addrs); + } /* fall through to examine arguments */ } else if (IsA(node, ConvertRowtypeExpr)) @@ -2034,6 +2184,7 @@ find_expr_references_walker(Node *node, ConvertRowtypeExpr *cvt = (ConvertRowtypeExpr *) node; /* since there is no function dependency, need to depend on type */ + LockNotPinnedObject(TypeRelationId, cvt->resulttype); add_object_address(TypeRelationId, cvt->resulttype, 0, context->addrs); } @@ -2041,6 +2192,7 @@ find_expr_references_walker(Node *node, { CollateExpr *coll = (CollateExpr *) node; + LockNotPinnedObject(CollationRelationId, coll->collOid); add_object_address(CollationRelationId, coll->collOid, 0, context->addrs); } @@ -2048,6 +2200,7 @@ find_expr_references_walker(Node *node, { RowExpr *rowexpr = (RowExpr *) node; + LockNotPinnedObject(TypeRelationId, rowexpr->row_typeid); add_object_address(TypeRelationId, rowexpr->row_typeid, 0, context->addrs); } @@ -2058,11 +2211,13 @@ find_expr_references_walker(Node *node, foreach(l, rcexpr->opnos) { + LockNotPinnedObject(OperatorRelationId, lfirst_oid(l)); add_object_address(OperatorRelationId, lfirst_oid(l), 0, context->addrs); } foreach(l, rcexpr->opfamilies) { + LockNotPinnedObject(OperatorFamilyRelationId, lfirst_oid(l)); add_object_address(OperatorFamilyRelationId, lfirst_oid(l), 0, context->addrs); } @@ -2072,6 +2227,7 @@ find_expr_references_walker(Node *node, { CoerceToDomain *cd = (CoerceToDomain *) node; + LockNotPinnedObject(TypeRelationId, cd->resulttype); add_object_address(TypeRelationId, cd->resulttype, 0, context->addrs); } @@ -2079,6 +2235,7 @@ find_expr_references_walker(Node *node, { NextValueExpr *nve = (NextValueExpr *) node; + LockNotPinnedObject(RelationRelationId, nve->seqid); add_object_address(RelationRelationId, nve->seqid, 0, context->addrs); } @@ -2087,19 +2244,26 @@ find_expr_references_walker(Node *node, OnConflictExpr *onconflict = (OnConflictExpr *) node; if (OidIsValid(onconflict->constraint)) + { + LockNotPinnedObject(ConstraintRelationId, onconflict->constraint); add_object_address(ConstraintRelationId, onconflict->constraint, 0, context->addrs); + } /* fall through to examine arguments */ } else if (IsA(node, SortGroupClause)) { SortGroupClause *sgc = (SortGroupClause *) node; + LockNotPinnedObject(OperatorRelationId, sgc->eqop); add_object_address(OperatorRelationId, sgc->eqop, 0, context->addrs); if (OidIsValid(sgc->sortop)) + { + LockNotPinnedObject(OperatorRelationId, sgc->sortop); add_object_address(OperatorRelationId, sgc->sortop, 0, context->addrs); + } return false; } else if (IsA(node, WindowClause)) @@ -2107,15 +2271,24 @@ find_expr_references_walker(Node *node, WindowClause *wc = (WindowClause *) node; if (OidIsValid(wc->startInRangeFunc)) + { + LockNotPinnedObject(ProcedureRelationId, wc->startInRangeFunc); add_object_address(ProcedureRelationId, wc->startInRangeFunc, 0, context->addrs); + } if (OidIsValid(wc->endInRangeFunc)) + { + LockNotPinnedObject(ProcedureRelationId, wc->endInRangeFunc); add_object_address(ProcedureRelationId, wc->endInRangeFunc, 0, context->addrs); + } if (OidIsValid(wc->inRangeColl) && wc->inRangeColl != DEFAULT_COLLATION_OID) + { + LockNotPinnedObject(CollationRelationId, wc->inRangeColl); add_object_address(CollationRelationId, wc->inRangeColl, 0, context->addrs); + } /* fall through to examine substructure */ } else if (IsA(node, CTECycleClause)) @@ -2123,14 +2296,23 @@ find_expr_references_walker(Node *node, CTECycleClause *cc = (CTECycleClause *) node; if (OidIsValid(cc->cycle_mark_type)) + { + LockNotPinnedObject(TypeRelationId, cc->cycle_mark_type); add_object_address(TypeRelationId, cc->cycle_mark_type, 0, context->addrs); + } if (OidIsValid(cc->cycle_mark_collation)) + { + LockNotPinnedObject(CollationRelationId, cc->cycle_mark_collation); add_object_address(CollationRelationId, cc->cycle_mark_collation, 0, context->addrs); + } if (OidIsValid(cc->cycle_mark_neop)) + { + LockNotPinnedObject(OperatorRelationId, cc->cycle_mark_neop); add_object_address(OperatorRelationId, cc->cycle_mark_neop, 0, context->addrs); + } /* fall through to examine substructure */ } else if (IsA(node, Query)) @@ -2163,6 +2345,7 @@ find_expr_references_walker(Node *node, switch (rte->rtekind) { case RTE_RELATION: + LockNotPinnedObject(RelationRelationId, rte->relid); add_object_address(RelationRelationId, rte->relid, 0, context->addrs); break; @@ -2215,12 +2398,18 @@ find_expr_references_walker(Node *node, rte = rt_fetch(query->resultRelation, query->rtable); if (rte->rtekind == RTE_RELATION) { + bool locked = false; foreach(lc, query->targetList) { TargetEntry *tle = (TargetEntry *) lfirst(lc); if (tle->resjunk) continue; /* ignore junk tlist items */ + if (!locked) + { + LockNotPinnedObject(RelationRelationId, rte->relid); + locked = true; + } add_object_address(RelationRelationId, rte->relid, tle->resno, context->addrs); } @@ -2232,6 +2421,7 @@ find_expr_references_walker(Node *node, */ foreach(lc, query->constraintDeps) { + LockNotPinnedObject(ConstraintRelationId, lfirst_oid(lc)); add_object_address(ConstraintRelationId, lfirst_oid(lc), 0, context->addrs); } @@ -2266,16 +2456,25 @@ find_expr_references_walker(Node *node, */ foreach(ct, rtfunc->funccoltypes) { + LockNotPinnedObject(TypeRelationId, lfirst_oid(ct)); add_object_address(TypeRelationId, lfirst_oid(ct), 0, context->addrs); } foreach(ct, rtfunc->funccolcollations) { Oid collid = lfirst_oid(ct); + bool locked = false; if (OidIsValid(collid) && collid != DEFAULT_COLLATION_OID) + { + if (!locked) + { + LockNotPinnedObject(CollationRelationId, collid); + locked = true; + } add_object_address(CollationRelationId, collid, 0, context->addrs); + } } } else if (IsA(node, TableFunc)) @@ -2288,22 +2487,32 @@ find_expr_references_walker(Node *node, */ foreach(ct, tf->coltypes) { + LockNotPinnedObject(TypeRelationId, lfirst_oid(ct)); add_object_address(TypeRelationId, lfirst_oid(ct), 0, context->addrs); } foreach(ct, tf->colcollations) { Oid collid = lfirst_oid(ct); + bool locked = false; if (OidIsValid(collid) && collid != DEFAULT_COLLATION_OID) + { + if (!locked) + { + LockNotPinnedObject(CollationRelationId, collid); + locked = true; + } add_object_address(CollationRelationId, collid, 0, context->addrs); + } } } else if (IsA(node, TableSampleClause)) { TableSampleClause *tsc = (TableSampleClause *) node; + LockNotPinnedObject(ProcedureRelationId, tsc->tsmhandler); add_object_address(ProcedureRelationId, tsc->tsmhandler, 0, context->addrs); /* fall through to examine arguments */ @@ -2354,9 +2563,12 @@ process_function_rte_ref(RangeTblEntry *rte, AttrNumber attnum, Assert(attnum - atts_done <= tupdesc->natts); if (OidIsValid(reltype)) /* can this fail? */ + { + LockNotPinnedObject(RelationRelationId, reltype); add_object_address(RelationRelationId, reltype, attnum - atts_done, context->addrs); + } return; } /* Nothing to do; function's result type is handled elsewhere */ diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 00074c8a94..1266101d90 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -844,6 +844,7 @@ AddNewAttributeTuples(Oid new_rel_oid, /* Add dependency info */ ObjectAddressSubSet(myself, RelationRelationId, new_rel_oid, i + 1); ObjectAddressSet(referenced, TypeRelationId, attr->atttypid); + LockNotPinnedObject(TypeRelationId, attr->atttypid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* The default collation is pinned, so don't bother recording it */ @@ -852,6 +853,7 @@ AddNewAttributeTuples(Oid new_rel_oid, { ObjectAddressSet(referenced, CollationRelationId, attr->attcollation); + LockNotPinnedObject(CollationRelationId, attr->attcollation); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } } @@ -1459,11 +1461,13 @@ heap_create_with_catalog(const char *relname, ObjectAddressSet(referenced, NamespaceRelationId, relnamespace); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(NamespaceRelationId, relnamespace); if (reloftypeid) { ObjectAddressSet(referenced, TypeRelationId, reloftypeid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, reloftypeid); } /* @@ -1477,6 +1481,7 @@ heap_create_with_catalog(const char *relname, { ObjectAddressSet(referenced, AccessMethodRelationId, accessmtd); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(AccessMethodRelationId, accessmtd); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); @@ -3391,6 +3396,7 @@ StorePartitionKey(Relation rel, { ObjectAddressSet(referenced, OperatorClassRelationId, partopclass[i]); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(OperatorClassRelationId, partopclass[i]); /* The default collation is pinned, so don't bother recording it */ if (OidIsValid(partcollation[i]) && @@ -3398,6 +3404,7 @@ StorePartitionKey(Relation rel, { ObjectAddressSet(referenced, CollationRelationId, partcollation[i]); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(CollationRelationId, partcollation[i]); } } diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index a819b4197c..d6d1abfcf5 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -1116,6 +1116,7 @@ index_create(Relation heapRelation, else { bool have_simple_col = false; + bool locked_object = false; addrs = new_object_addresses(); @@ -1128,6 +1129,12 @@ index_create(Relation heapRelation, heapRelationId, indexInfo->ii_IndexAttrNumbers[i]); add_exact_object_address(&referenced, addrs); + + if (!locked_object) + { + LockNotPinnedObject(RelationRelationId, heapRelationId); + locked_object = true; + } have_simple_col = true; } } @@ -1143,6 +1150,8 @@ index_create(Relation heapRelation, ObjectAddressSet(referenced, RelationRelationId, heapRelationId); add_exact_object_address(&referenced, addrs); + + LockNotPinnedObject(RelationRelationId, heapRelationId); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_AUTO); @@ -1158,9 +1167,13 @@ index_create(Relation heapRelation, if (OidIsValid(parentIndexRelid)) { ObjectAddressSet(referenced, RelationRelationId, parentIndexRelid); + + LockNotPinnedObject(RelationRelationId, parentIndexRelid); recordDependencyOn(&myself, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, heapRelationId); + + LockNotPinnedObject(RelationRelationId, heapRelationId); recordDependencyOn(&myself, &referenced, DEPENDENCY_PARTITION_SEC); } @@ -1176,6 +1189,7 @@ index_create(Relation heapRelation, { ObjectAddressSet(referenced, CollationRelationId, collationIds[i]); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(CollationRelationId, collationIds[i]); } } @@ -1184,6 +1198,7 @@ index_create(Relation heapRelation, { ObjectAddressSet(referenced, OperatorClassRelationId, opclassIds[i]); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(OperatorClassRelationId, opclassIds[i]); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); @@ -1988,6 +2003,14 @@ index_constraint_create(Relation heapRelation, */ ObjectAddressSet(myself, ConstraintRelationId, conOid); ObjectAddressSet(idxaddr, RelationRelationId, indexRelationId); + + /* + * CommandCounterIncrement() here to ensure the new constraint entry is + * visible when LockNotPinnedObject() will check its existence before + * recording the dependencies. + */ + CommandCounterIncrement(); + LockNotPinnedObject(ConstraintRelationId, conOid); recordDependencyOn(&idxaddr, &myself, DEPENDENCY_INTERNAL); /* @@ -1999,9 +2022,12 @@ index_constraint_create(Relation heapRelation, ObjectAddress referenced; ObjectAddressSet(referenced, ConstraintRelationId, parentConstraintId); + LockNotPinnedObject(ConstraintRelationId, parentConstraintId); recordDependencyOn(&myself, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, RelationGetRelid(heapRelation)); + + LockNotPinnedObject(RelationRelationId, RelationGetRelid(heapRelation)); recordDependencyOn(&myself, &referenced, DEPENDENCY_PARTITION_SEC); } diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 2983b9180f..d3af0ae726 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -2590,6 +2590,63 @@ get_object_namespace(const ObjectAddress *address) return oid; } +/* + * ObjectByIdExist + * + * Return whether the given object exists. + * + * Works for most catalogs, if no special processing is needed. + */ +bool +ObjectByIdExist(const ObjectAddress *address) +{ + HeapTuple tuple; + int cache; + const ObjectPropertyType *property; + + property = get_object_property_data(address->classId); + + cache = property->oid_catcache_id; + + if (cache >= 0) + { + /* Fetch tuple from syscache. */ + tuple = SearchSysCache1(cache, ObjectIdGetDatum(address->objectId)); + + if (!HeapTupleIsValid(tuple)) + { + return false; + } + + ReleaseSysCache(tuple); + + return true; + } + else + { + Relation rel; + ScanKeyData skey[1]; + SysScanDesc scan; + + rel = table_open(address->classId, AccessShareLock); + + ScanKeyInit(&skey[0], + get_object_attnum_oid(address->classId), + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(address->objectId)); + + scan = systable_beginscan(rel, get_object_oid_index(address->classId), true, + NULL, 1, skey); + + /* we expect exactly one match */ + tuple = systable_getnext(scan); + systable_endscan(scan); + table_close(rel, AccessShareLock); + + return (HeapTupleIsValid(tuple)); + } +} + /* * Return ObjectType for the given object type as given by * getObjectTypeDescription; if no valid ObjectType code exists, but it's a diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 90fc7db949..a47e3c5507 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -748,12 +748,14 @@ AggregateCreate(const char *aggName, /* Depends on transition function */ ObjectAddressSet(referenced, ProcedureRelationId, transfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, transfn); /* Depends on final function, if any */ if (OidIsValid(finalfn)) { ObjectAddressSet(referenced, ProcedureRelationId, finalfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, finalfn); } /* Depends on combine function, if any */ @@ -761,6 +763,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, ProcedureRelationId, combinefn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, combinefn); } /* Depends on serialization function, if any */ @@ -768,6 +771,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, ProcedureRelationId, serialfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, serialfn); } /* Depends on deserialization function, if any */ @@ -775,6 +779,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, ProcedureRelationId, deserialfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, deserialfn); } /* Depends on forward transition function, if any */ @@ -782,6 +787,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, ProcedureRelationId, mtransfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, mtransfn); } /* Depends on inverse transition function, if any */ @@ -789,6 +795,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, ProcedureRelationId, minvtransfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, minvtransfn); } /* Depends on final function, if any */ @@ -796,6 +803,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, ProcedureRelationId, mfinalfn); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, mfinalfn); } /* Depends on sort operator, if any */ @@ -803,6 +811,7 @@ AggregateCreate(const char *aggName, { ObjectAddressSet(referenced, OperatorRelationId, sortop); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(OperatorRelationId, sortop); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c index 003ae70b4d..dcce454f00 100644 --- a/src/backend/catalog/pg_attrdef.c +++ b/src/backend/catalog/pg_attrdef.c @@ -178,6 +178,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, colobject.objectId = RelationGetRelid(rel); colobject.objectSubId = attnum; + LockNotPinnedObject(RelationRelationId, RelationGetRelid(rel)); recordDependencyOn(&defobject, &colobject, attgenerated ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); diff --git a/src/backend/catalog/pg_cast.c b/src/backend/catalog/pg_cast.c index 5a5b855d51..d3707e424c 100644 --- a/src/backend/catalog/pg_cast.c +++ b/src/backend/catalog/pg_cast.c @@ -97,16 +97,19 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, /* dependency on source type */ ObjectAddressSet(referenced, TypeRelationId, sourcetypeid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, sourcetypeid); /* dependency on target type */ ObjectAddressSet(referenced, TypeRelationId, targettypeid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, targettypeid); /* dependency on function */ if (OidIsValid(funcid)) { ObjectAddressSet(referenced, ProcedureRelationId, funcid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, funcid); } /* dependencies on casts required for function */ @@ -114,11 +117,13 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, { ObjectAddressSet(referenced, CastRelationId, incastid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(CastRelationId, incastid); } if (OidIsValid(outcastid)) { ObjectAddressSet(referenced, CastRelationId, outcastid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(CastRelationId, outcastid); } record_object_address_dependencies(&myself, addrs, behavior); diff --git a/src/backend/catalog/pg_collation.c b/src/backend/catalog/pg_collation.c index 7f2f701229..78498b8c20 100644 --- a/src/backend/catalog/pg_collation.c +++ b/src/backend/catalog/pg_collation.c @@ -218,6 +218,7 @@ CollationCreate(const char *collname, Oid collnamespace, referenced.classId = NamespaceRelationId; referenced.objectId = collnamespace; referenced.objectSubId = 0; + LockNotPinnedObject(NamespaceRelationId, collnamespace); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* create dependency on owner */ diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c index 3baf9231ed..c4cdbd7c58 100644 --- a/src/backend/catalog/pg_constraint.c +++ b/src/backend/catalog/pg_constraint.c @@ -252,17 +252,26 @@ CreateConstraintEntry(const char *constraintName, if (constraintNTotalKeys > 0) { + bool locked_object = false; + for (i = 0; i < constraintNTotalKeys; i++) { ObjectAddressSubSet(relobject, RelationRelationId, relId, constraintKey[i]); add_exact_object_address(&relobject, addrs_auto); + + if (!locked_object) + { + LockNotPinnedObject(RelationRelationId, relId); + locked_object = true; + } } } else { ObjectAddressSet(relobject, RelationRelationId, relId); add_exact_object_address(&relobject, addrs_auto); + LockNotPinnedObject(RelationRelationId, relId); } } @@ -275,6 +284,7 @@ CreateConstraintEntry(const char *constraintName, ObjectAddressSet(domobject, TypeRelationId, domainId); add_exact_object_address(&domobject, addrs_auto); + LockNotPinnedObject(TypeRelationId, domainId); } record_object_address_dependencies(&conobject, addrs_auto, @@ -294,17 +304,26 @@ CreateConstraintEntry(const char *constraintName, if (foreignNKeys > 0) { + bool locked_object = false; + for (i = 0; i < foreignNKeys; i++) { ObjectAddressSubSet(relobject, RelationRelationId, foreignRelId, foreignKey[i]); add_exact_object_address(&relobject, addrs_normal); + + if (!locked_object) + { + LockNotPinnedObject(RelationRelationId, foreignRelId); + locked_object = true; + } } } else { ObjectAddressSet(relobject, RelationRelationId, foreignRelId); add_exact_object_address(&relobject, addrs_normal); + LockNotPinnedObject(RelationRelationId, foreignRelId); } } @@ -320,6 +339,7 @@ CreateConstraintEntry(const char *constraintName, ObjectAddressSet(relobject, RelationRelationId, indexRelId); add_exact_object_address(&relobject, addrs_normal); + LockNotPinnedObject(RelationRelationId, indexRelId); } if (foreignNKeys > 0) @@ -339,15 +359,18 @@ CreateConstraintEntry(const char *constraintName, { oprobject.objectId = pfEqOp[i]; add_exact_object_address(&oprobject, addrs_normal); + LockNotPinnedObject(OperatorRelationId, pfEqOp[i]); if (ppEqOp[i] != pfEqOp[i]) { oprobject.objectId = ppEqOp[i]; add_exact_object_address(&oprobject, addrs_normal); + LockNotPinnedObject(OperatorRelationId, ppEqOp[i]); } if (ffEqOp[i] != pfEqOp[i]) { oprobject.objectId = ffEqOp[i]; add_exact_object_address(&oprobject, addrs_normal); + LockNotPinnedObject(OperatorRelationId, ffEqOp[i]); } } } @@ -858,9 +881,12 @@ ConstraintSetParentConstraint(Oid childConstrId, ObjectAddressSet(depender, ConstraintRelationId, childConstrId); ObjectAddressSet(referenced, ConstraintRelationId, parentConstrId); + LockNotPinnedObject(ConstraintRelationId, parentConstrId); recordDependencyOn(&depender, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, childTableId); + + LockNotPinnedObject(RelationRelationId, childTableId); recordDependencyOn(&depender, &referenced, DEPENDENCY_PARTITION_SEC); } else diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c index 0770878eac..25881654d6 100644 --- a/src/backend/catalog/pg_conversion.c +++ b/src/backend/catalog/pg_conversion.c @@ -116,12 +116,14 @@ ConversionCreate(const char *conname, Oid connamespace, referenced.classId = ProcedureRelationId; referenced.objectId = conproc; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, conproc); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* create dependency on namespace */ referenced.classId = NamespaceRelationId; referenced.objectId = connamespace; referenced.objectSubId = 0; + LockNotPinnedObject(NamespaceRelationId, connamespace); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* create dependency on owner */ diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c index cfd7ef51df..ebca5a452b 100644 --- a/src/backend/catalog/pg_depend.c +++ b/src/backend/catalog/pg_depend.c @@ -20,21 +20,21 @@ #include "catalog/catalog.h" #include "catalog/dependency.h" #include "catalog/indexing.h" +#include "catalog/pg_auth_members.h" #include "catalog/pg_constraint.h" #include "catalog/pg_depend.h" #include "catalog/pg_extension.h" #include "catalog/partition.h" #include "commands/extension.h" #include "miscadmin.h" +#include "storage/lmgr.h" +#include "storage/lock.h" #include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/syscache.h" #include "utils/rel.h" -static bool isObjectPinned(const ObjectAddress *object); - - /* * Record a dependency between 2 objects via their respective objectAddress. * The first argument is the dependent object, the second the one it @@ -100,6 +100,37 @@ recordMultipleDependencies(const ObjectAddress *depender, slot_init_count = 0; for (i = 0; i < nreferenced; i++, referenced++) { +#ifdef USE_ASSERT_CHECKING + if (!isObjectPinned(referenced)) + { + if (referenced->classId != RelationRelationId) + { + LOCKTAG tag; + + SET_LOCKTAG_OBJECT(tag, + MyDatabaseId, + referenced->classId, + referenced->objectId, + 0); + /* assert the referenced object is locked */ + Assert(LockHeldByMe(&tag, AccessShareLock, false)); + } + else + { + Assert(!IsSharedRelation(referenced->objectId)); + + /* + * Assert the referenced object is locked if it should be + * visible (see the comment related to LockNotPinnedObject() + * in TypeCreate()). + */ + Assert(!ObjectByIdExist(referenced) || + CheckRelationOidLockedByMe(referenced->objectId, + AccessShareLock, true)); + } + } +#endif + /* * If the referenced object is pinned by the system, there's no real * need to record dependencies on it. This saves lots of space in @@ -239,6 +270,7 @@ recordDependencyOnCurrentExtension(const ObjectAddress *object, extension.objectId = CurrentExtensionObject; extension.objectSubId = 0; + LockNotPinnedObject(ExtensionRelationId, CurrentExtensionObject); recordDependencyOn(object, &extension, DEPENDENCY_EXTENSION); } } @@ -706,7 +738,7 @@ changeDependenciesOn(Oid refClassId, Oid oldRefObjectId, * The passed subId, if any, is ignored; we assume that only whole objects * are pinned (and that this implies pinning their components). */ -static bool +bool isObjectPinned(const ObjectAddress *object) { return IsPinnedObject(object->classId, object->objectId); diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 65b45a424a..e8374eec88 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -251,6 +251,16 @@ OperatorShellMake(const char *operatorName, values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(InvalidOid); values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(InvalidOid); + /* Lock dependent objects */ + if (OidIsValid(operatorNamespace)) + LockNotPinnedObject(NamespaceRelationId, operatorNamespace); + + if (OidIsValid(leftTypeId)) + LockNotPinnedObject(TypeRelationId, leftTypeId); + + if (OidIsValid(rightTypeId)) + LockNotPinnedObject(TypeRelationId, rightTypeId); + /* * create a new operator tuple */ @@ -513,6 +523,15 @@ OperatorCreate(const char *operatorName, CatalogTupleInsert(pg_operator_desc, tup); } + /* Lock dependent objects */ + LockNotPinnedObject(NamespaceRelationId, operatorNamespace); + LockNotPinnedObject(TypeRelationId, leftTypeId); + LockNotPinnedObject(TypeRelationId, rightTypeId); + LockNotPinnedObject(TypeRelationId, operResultType); + LockNotPinnedObject(ProcedureRelationId, procedureId); + LockNotPinnedObject(ProcedureRelationId, restrictionId); + LockNotPinnedObject(ProcedureRelationId, joinId); + /* Add dependencies for the entry */ address = makeOperatorDependencies(tup, true, isUpdate); diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 528c17cd7f..116e524390 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -593,6 +593,13 @@ ProcedureCreate(const char *procedureName, if (is_update) deleteDependencyRecordsFor(ProcedureRelationId, retval, true); + /* + * CommandCounterIncrement() here to ensure the new function entry is + * visible when LockNotPinnedObject() will check its existence before + * recording the dependencies. + */ + CommandCounterIncrement(); + addrs = new_object_addresses(); ObjectAddressSet(myself, ProcedureRelationId, retval); @@ -600,20 +607,24 @@ ProcedureCreate(const char *procedureName, /* dependency on namespace */ ObjectAddressSet(referenced, NamespaceRelationId, procNamespace); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(NamespaceRelationId, procNamespace); /* dependency on implementation language */ ObjectAddressSet(referenced, LanguageRelationId, languageObjectId); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(LanguageRelationId, languageObjectId); /* dependency on return type */ ObjectAddressSet(referenced, TypeRelationId, returnType); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, returnType); /* dependency on transform used by return type, if any */ if ((trfid = get_transform_oid(returnType, languageObjectId, true))) { ObjectAddressSet(referenced, TransformRelationId, trfid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TransformRelationId, trfid); } /* dependency on parameter types */ @@ -621,12 +632,14 @@ ProcedureCreate(const char *procedureName, { ObjectAddressSet(referenced, TypeRelationId, allParams[i]); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, allParams[i]); /* dependency on transform used by parameter type, if any */ if ((trfid = get_transform_oid(allParams[i], languageObjectId, true))) { ObjectAddressSet(referenced, TransformRelationId, trfid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TransformRelationId, trfid); } } @@ -635,6 +648,7 @@ ProcedureCreate(const char *procedureName, { ObjectAddressSet(referenced, ProcedureRelationId, prosupport); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, prosupport); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); @@ -674,9 +688,6 @@ ProcedureCreate(const char *procedureName, ArrayType *set_items = NULL; int save_nestlevel = 0; - /* Advance command counter so new tuple can be seen by validator */ - CommandCounterIncrement(); - /* * Set per-function configuration parameters so that the validation is * done with the environment the function expects. However, if diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index 0602398a54..b44a7f9d78 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -438,10 +438,13 @@ publication_add_relation(Oid pubid, PublicationRelInfo *pri, /* Add dependency on the publication */ ObjectAddressSet(referenced, PublicationRelationId, pubid); + LockNotPinnedObject(PublicationRelationId, pubid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); /* Add dependency on the relation */ ObjectAddressSet(referenced, RelationRelationId, relid); + + LockNotPinnedObject(RelationRelationId, relid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); /* Add dependency on the objects mentioned in the qualifications */ @@ -454,6 +457,8 @@ publication_add_relation(Oid pubid, PublicationRelInfo *pri, for (int i = 0; i < natts; i++) { ObjectAddressSubSet(referenced, RelationRelationId, relid, attarray[i]); + + LockNotPinnedObject(RelationRelationId, relid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } @@ -661,10 +666,12 @@ publication_add_schema(Oid pubid, Oid schemaid, bool if_not_exists) /* Add dependency on the publication */ ObjectAddressSet(referenced, PublicationRelationId, pubid); + LockNotPinnedObject(PublicationRelationId, pubid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); /* Add dependency on the schema */ ObjectAddressSet(referenced, NamespaceRelationId, schemaid); + LockNotPinnedObject(NamespaceRelationId, schemaid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); /* Close the table */ diff --git a/src/backend/catalog/pg_range.c b/src/backend/catalog/pg_range.c index 501a6ba410..e5b5a0b6f8 100644 --- a/src/backend/catalog/pg_range.c +++ b/src/backend/catalog/pg_range.c @@ -70,26 +70,31 @@ RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation, ObjectAddressSet(referenced, TypeRelationId, rangeSubType); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, rangeSubType); ObjectAddressSet(referenced, OperatorClassRelationId, rangeSubOpclass); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(OperatorClassRelationId, rangeSubOpclass); if (OidIsValid(rangeCollation)) { ObjectAddressSet(referenced, CollationRelationId, rangeCollation); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(CollationRelationId, rangeCollation); } if (OidIsValid(rangeCanonical)) { ObjectAddressSet(referenced, ProcedureRelationId, rangeCanonical); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, rangeCanonical); } if (OidIsValid(rangeSubDiff)) { ObjectAddressSet(referenced, ProcedureRelationId, rangeSubDiff); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, rangeSubDiff); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); @@ -99,6 +104,7 @@ RangeCreate(Oid rangeTypeOid, Oid rangeSubType, Oid rangeCollation, referencing.classId = TypeRelationId; referencing.objectId = multirangeTypeOid; referencing.objectSubId = 0; + LockNotPinnedObject(TypeRelationId, rangeTypeOid); recordDependencyOn(&referencing, &myself, DEPENDENCY_INTERNAL); table_close(pg_range, RowExclusiveLock); diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index 395dec8ed8..82ee7bc2e3 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -157,6 +157,12 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId) * Create dependencies. We can/must skip this in bootstrap mode. */ if (!IsBootstrapProcessingMode()) + { + /* Lock dependent objects */ + LockNotPinnedObject(NamespaceRelationId, typeNamespace); + LockNotPinnedObject(ProcedureRelationId, F_SHELL_IN); + LockNotPinnedObject(ProcedureRelationId, F_SHELL_OUT); + GenerateTypeDependencies(tup, pg_type_desc, NULL, @@ -166,6 +172,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId) false, true, /* make extension dependency */ false); + } /* Post creation hook for new shell type */ InvokeObjectPostCreateHook(TypeRelationId, typoid, 0); @@ -494,6 +501,37 @@ TypeCreate(Oid newTypeOid, * Create dependencies. We can/must skip this in bootstrap mode. */ if (!IsBootstrapProcessingMode()) + { + /* + * CommandCounterIncrement() here to ensure the new type entry is + * visible when LockNotPinnedObject() will check its existence before + * recording the dependencies. + */ + CommandCounterIncrement(); + + /* Lock dependent objects */ + LockNotPinnedObject(NamespaceRelationId, typeNamespace); + LockNotPinnedObject(ProcedureRelationId, inputProcedure); + LockNotPinnedObject(ProcedureRelationId, outputProcedure); + LockNotPinnedObject(ProcedureRelationId, receiveProcedure); + LockNotPinnedObject(ProcedureRelationId, sendProcedure); + LockNotPinnedObject(ProcedureRelationId, typmodinProcedure); + LockNotPinnedObject(ProcedureRelationId, typmodoutProcedure); + LockNotPinnedObject(ProcedureRelationId, analyzeProcedure); + LockNotPinnedObject(ProcedureRelationId, subscriptProcedure); + LockNotPinnedObject(TypeRelationId, baseType); + LockNotPinnedObject(CollationRelationId, typeCollation); + LockNotPinnedObject(TypeRelationId, elementType); + + /* + * No need to call LockRelationOid() (through LockNotPinnedObject()) + * on relationOid as relationOid is set to an InvalidOid or to a new + * Oid not added to pg_class yet (In heap_create_with_catalog(), + * AddNewRelationType() is called before AddNewRelationTuple()). + */ + if (relationKind == RELKIND_COMPOSITE_TYPE) + LockNotPinnedObject(TypeRelationId, typeObjectId); + GenerateTypeDependencies(tup, pg_type_desc, (defaultTypeBin ? @@ -505,6 +543,7 @@ TypeCreate(Oid newTypeOid, isDependentType, true, /* make extension dependency */ rebuildDeps); + } /* Post creation hook for new type */ InvokeObjectPostCreateHook(TypeRelationId, typeObjectId, 0); diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c index 738bc46ae8..a4d8342ca1 100644 --- a/src/backend/catalog/toasting.c +++ b/src/backend/catalog/toasting.c @@ -367,6 +367,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, toastobject.objectId = toast_relid; toastobject.objectSubId = 0; + LockNotPinnedObject(RelationRelationId, relOid); recordDependencyOn(&toastobject, &baseobject, DEPENDENCY_INTERNAL); } diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 4f99ebb447..57e86f576a 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -501,7 +501,10 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre currexts = getAutoExtensionsOfObject(address.classId, address.objectId); if (!list_member_oid(currexts, refAddr.objectId)) + { + LockNotPinnedObject(refAddr.classId, refAddr.objectId); recordDependencyOn(&address, &refAddr, DEPENDENCY_AUTO_EXTENSION); + } } return address; @@ -807,6 +810,7 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid) pfree(replaces); /* update dependency to point to the new schema */ + LockNotPinnedObject(NamespaceRelationId, nspOid); if (changeDependencyFor(classId, objid, NamespaceRelationId, oldNspOid, nspOid) != 1) elog(ERROR, "could not change schema dependency for object %u", diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c index aaa0f9a1dc..8616a7c9fa 100644 --- a/src/backend/commands/amcmds.c +++ b/src/backend/commands/amcmds.c @@ -104,6 +104,7 @@ CreateAccessMethod(CreateAmStmt *stmt) referenced.objectId = amhandler; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, amhandler); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); recordDependencyOnCurrentExtension(&myself, false); diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 78f96789b0..fb95d17738 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -1272,6 +1272,7 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, */ if (relam1 != relam2) { + LockNotPinnedObject(AccessMethodRelationId, relam2); if (changeDependencyFor(RelationRelationId, r1, AccessMethodRelationId, @@ -1280,6 +1281,8 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, elog(ERROR, "could not change access method dependency for relation \"%s.%s\"", get_namespace_name(get_rel_namespace(r1)), get_rel_name(r1)); + + LockNotPinnedObject(AccessMethodRelationId, relam1); if (changeDependencyFor(RelationRelationId, r2, AccessMethodRelationId, @@ -1381,6 +1384,8 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, { baseobject.objectId = r1; toastobject.objectId = relform1->reltoastrelid; + + LockNotPinnedObject(RelationRelationId, r1); recordDependencyOn(&toastobject, &baseobject, DEPENDENCY_INTERNAL); } @@ -1389,6 +1394,8 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, { baseobject.objectId = r2; toastobject.objectId = relform2->reltoastrelid; + + LockNotPinnedObject(RelationRelationId, r2); recordDependencyOn(&toastobject, &baseobject, DEPENDENCY_INTERNAL); } diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 7a5ed6b985..8d0cdec59e 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -327,6 +327,7 @@ insert_event_trigger_tuple(const char *trigname, const char *eventname, Oid evtO referenced.classId = ProcedureRelationId; referenced.objectId = funcoid; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, funcoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* Depend on extension, if any. */ diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index 1643c8c69a..669a5d6dd8 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -1924,6 +1924,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner, ObjectAddressSet(nsp, NamespaceRelationId, schemaOid); add_exact_object_address(&nsp, refobjs); + LockNotPinnedObject(NamespaceRelationId, schemaOid); foreach(lc, requiredExtensions) { @@ -1932,6 +1933,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner, ObjectAddressSet(otherext, ExtensionRelationId, reqext); add_exact_object_address(&otherext, refobjs); + LockNotPinnedObject(ExtensionRelationId, reqext); } /* Record all of them (this includes duplicate elimination) */ @@ -2968,6 +2970,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o table_close(extRel, RowExclusiveLock); /* update dependency to point to the new schema */ + LockNotPinnedObject(NamespaceRelationId, nspOid); if (changeDependencyFor(ExtensionRelationId, extensionOid, NamespaceRelationId, oldNspOid, nspOid) != 1) elog(ERROR, "could not change schema dependency for extension %s", @@ -3258,6 +3261,7 @@ ApplyExtensionUpdates(Oid extensionOid, otherext.objectId = reqext; otherext.objectSubId = 0; + LockNotPinnedObject(ExtensionRelationId, reqext); recordDependencyOn(&myself, &otherext, DEPENDENCY_NORMAL); } @@ -3414,6 +3418,7 @@ ExecAlterExtensionContentsRecurse(AlterExtensionContentsStmt *stmt, /* * OK, add the dependency. */ + LockNotPinnedObject(extension.classId, extension.objectId); recordDependencyOn(&object, &extension, DEPENDENCY_EXTENSION); /* diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c index cf61bbac1f..735bca486c 100644 --- a/src/backend/commands/foreigncmds.c +++ b/src/backend/commands/foreigncmds.c @@ -642,6 +642,7 @@ CreateForeignDataWrapper(ParseState *pstate, CreateFdwStmt *stmt) referenced.classId = ProcedureRelationId; referenced.objectId = fdwhandler; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, fdwhandler); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } @@ -650,6 +651,7 @@ CreateForeignDataWrapper(ParseState *pstate, CreateFdwStmt *stmt) referenced.classId = ProcedureRelationId; referenced.objectId = fdwvalidator; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, fdwvalidator); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } @@ -811,6 +813,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt) referenced.classId = ProcedureRelationId; referenced.objectId = fdwhandler; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, fdwhandler); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } @@ -819,6 +822,7 @@ AlterForeignDataWrapper(ParseState *pstate, AlterFdwStmt *stmt) referenced.classId = ProcedureRelationId; referenced.objectId = fdwvalidator; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, fdwvalidator); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } } @@ -951,6 +955,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt) referenced.classId = ForeignDataWrapperRelationId; referenced.objectId = fdw->fdwid; referenced.objectSubId = 0; + LockNotPinnedObject(ForeignDataWrapperRelationId, fdw->fdwid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); recordDependencyOnOwner(ForeignServerRelationId, srvId, ownerId); @@ -1195,6 +1200,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt) referenced.classId = ForeignServerRelationId; referenced.objectId = srv->serverid; referenced.objectSubId = 0; + LockNotPinnedObject(ForeignServerRelationId, srv->serverid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); if (OidIsValid(useId)) @@ -1472,6 +1478,7 @@ CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid) referenced.classId = ForeignServerRelationId; referenced.objectId = server->serverid; referenced.objectSubId = 0; + LockNotPinnedObject(ForeignServerRelationId, server->serverid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); table_close(ftrel, RowExclusiveLock); diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 6593fd7d81..8207ef08b3 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -1446,6 +1446,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt) /* Add or replace dependency on support function */ if (OidIsValid(procForm->prosupport)) { + LockNotPinnedObject(ProcedureRelationId, newsupport); if (changeDependencyFor(ProcedureRelationId, funcOid, ProcedureRelationId, procForm->prosupport, newsupport) != 1) @@ -1459,6 +1460,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt) referenced.classId = ProcedureRelationId; referenced.objectId = newsupport; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, newsupport); recordDependencyOn(&address, &referenced, DEPENDENCY_NORMAL); } @@ -1962,21 +1964,25 @@ CreateTransform(CreateTransformStmt *stmt) /* dependency on language */ ObjectAddressSet(referenced, LanguageRelationId, langid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(LanguageRelationId, langid); /* dependency on type */ ObjectAddressSet(referenced, TypeRelationId, typeid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(TypeRelationId, typeid); /* dependencies on functions */ if (OidIsValid(fromsqlfuncid)) { ObjectAddressSet(referenced, ProcedureRelationId, fromsqlfuncid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, fromsqlfuncid); } if (OidIsValid(tosqlfuncid)) { ObjectAddressSet(referenced, ProcedureRelationId, tosqlfuncid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, tosqlfuncid); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 2caab88aa5..e6ff8476e8 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -4380,8 +4380,10 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid) ObjectAddressSet(parentIdx, RelationRelationId, parentOid); ObjectAddressSet(partitionTbl, RelationRelationId, partitionIdx->rd_index->indrelid); + LockNotPinnedObject(RelationRelationId, parentOid); recordDependencyOn(&partIdx, &parentIdx, DEPENDENCY_PARTITION_PRI); + LockNotPinnedObject(RelationRelationId, partitionIdx->rd_index->indrelid); recordDependencyOn(&partIdx, &partitionTbl, DEPENDENCY_PARTITION_SEC); } diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index b8b5c147c5..e70afd216c 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -298,12 +298,14 @@ CreateOpFamily(CreateOpFamilyStmt *stmt, const char *opfname, referenced.classId = AccessMethodRelationId; referenced.objectId = amoid; referenced.objectSubId = 0; + LockNotPinnedObject(AccessMethodRelationId, amoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); /* dependency on namespace */ referenced.classId = NamespaceRelationId; referenced.objectId = namespaceoid; referenced.objectSubId = 0; + LockNotPinnedObject(NamespaceRelationId, namespaceoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* dependency on owner */ @@ -725,18 +727,21 @@ DefineOpClass(CreateOpClassStmt *stmt) referenced.classId = NamespaceRelationId; referenced.objectId = namespaceoid; referenced.objectSubId = 0; + LockNotPinnedObject(NamespaceRelationId, namespaceoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* dependency on opfamily */ referenced.classId = OperatorFamilyRelationId; referenced.objectId = opfamilyoid; referenced.objectSubId = 0; + LockNotPinnedObject(OperatorFamilyRelationId, opfamilyoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); /* dependency on indexed datatype */ referenced.classId = TypeRelationId; referenced.objectId = typeoid; referenced.objectSubId = 0; + LockNotPinnedObject(TypeRelationId, typeoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); /* dependency on storage datatype */ @@ -745,6 +750,7 @@ DefineOpClass(CreateOpClassStmt *stmt) referenced.classId = TypeRelationId; referenced.objectId = storageoid; referenced.objectSubId = 0; + LockNotPinnedObject(TypeRelationId, storageoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } @@ -1486,6 +1492,13 @@ storeOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid, heap_freetuple(tup); + /* + * CommandCounterIncrement() here to ensure the new operator entry is + * visible when LockNotPinnedObject() will check its existence before + * recording the dependencies. + */ + CommandCounterIncrement(); + /* Make its dependencies */ myself.classId = AccessMethodOperatorRelationId; myself.objectId = entryoid; @@ -1496,6 +1509,7 @@ storeOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid, referenced.objectSubId = 0; /* see comments in amapi.h about dependency strength */ + LockNotPinnedObject(OperatorRelationId, op->object); recordDependencyOn(&myself, &referenced, op->ref_is_hard ? DEPENDENCY_NORMAL : DEPENDENCY_AUTO); @@ -1504,6 +1518,7 @@ storeOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid, referenced.objectId = op->refobjid; referenced.objectSubId = 0; + LockNotPinnedObject(referenced.classId, op->refobjid); recordDependencyOn(&myself, &referenced, op->ref_is_hard ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); @@ -1514,6 +1529,7 @@ storeOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid, referenced.objectId = op->sortfamily; referenced.objectSubId = 0; + LockNotPinnedObject(OperatorFamilyRelationId, op->sortfamily); recordDependencyOn(&myself, &referenced, op->ref_is_hard ? DEPENDENCY_NORMAL : DEPENDENCY_AUTO); } @@ -1597,6 +1613,7 @@ storeProcedures(List *opfamilyname, Oid amoid, Oid opfamilyoid, referenced.objectSubId = 0; /* see comments in amapi.h about dependency strength */ + LockNotPinnedObject(ProcedureRelationId, proc->object); recordDependencyOn(&myself, &referenced, proc->ref_is_hard ? DEPENDENCY_NORMAL : DEPENDENCY_AUTO); @@ -1605,6 +1622,7 @@ storeProcedures(List *opfamilyname, Oid amoid, Oid opfamilyoid, referenced.objectId = proc->refobjid; referenced.objectSubId = 0; + LockNotPinnedObject(referenced.classId, proc->refobjid); recordDependencyOn(&myself, &referenced, proc->ref_is_hard ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index 5872a3e192..58a69e7cc2 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -33,6 +33,7 @@ #include "access/htup_details.h" #include "access/table.h" +#include "catalog/dependency.h" #include "catalog/indexing.h" #include "catalog/objectaccess.h" #include "catalog/pg_namespace.h" @@ -656,11 +657,15 @@ AlterOperator(AlterOperatorStmt *stmt) { replaces[Anum_pg_operator_oprrest - 1] = true; values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(restrictionOid); + if (OidIsValid(restrictionOid)) + LockNotPinnedObject(ProcedureRelationId, restrictionOid); } if (updateJoin) { replaces[Anum_pg_operator_oprjoin - 1] = true; values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(joinOid); + if (OidIsValid(joinOid)) + LockNotPinnedObject(ProcedureRelationId, joinOid); } if (OidIsValid(commutatorOid)) { @@ -688,6 +693,31 @@ AlterOperator(AlterOperatorStmt *stmt) CatalogTupleUpdate(catalog, &tup->t_self, tup); + + /* Lock dependent objects */ + oprForm = (Form_pg_operator) GETSTRUCT(tup); + + if (OidIsValid(oprForm->oprnamespace)) + LockNotPinnedObject(NamespaceRelationId, oprForm->oprnamespace); + + if (OidIsValid(oprForm->oprleft)) + LockNotPinnedObject(TypeRelationId, oprForm->oprleft); + + if (OidIsValid(oprForm->oprright)) + LockNotPinnedObject(TypeRelationId, oprForm->oprright); + + if (OidIsValid(oprForm->oprresult)) + LockNotPinnedObject(TypeRelationId, oprForm->oprresult); + + if (OidIsValid(oprForm->oprcode)) + LockNotPinnedObject(ProcedureRelationId, oprForm->oprcode); + + if (OidIsValid(oprForm->oprrest)) + LockNotPinnedObject(ProcedureRelationId, oprForm->oprrest); + + if (OidIsValid(oprForm->oprjoin)) + LockNotPinnedObject(ProcedureRelationId, oprForm->oprjoin); + address = makeOperatorDependencies(tup, false, true); if (OidIsValid(commutatorOid) || OidIsValid(negatorOid)) diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index 6ff3eba824..9da98cbeec 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -722,6 +722,7 @@ CreatePolicy(CreatePolicyStmt *stmt) myself.objectId = policy_id; myself.objectSubId = 0; + LockNotPinnedObject(RelationRelationId, table_id); recordDependencyOn(&myself, &target, DEPENDENCY_AUTO); recordDependencyOnExpr(&myself, qual, qual_pstate->p_rtable, @@ -1053,6 +1054,7 @@ AlterPolicy(AlterPolicyStmt *stmt) myself.objectId = policy_id; myself.objectSubId = 0; + LockNotPinnedObject(RelationRelationId, table_id); recordDependencyOn(&myself, &target, DEPENDENCY_AUTO); recordDependencyOnExpr(&myself, qual, qual_parse_rtable, DEPENDENCY_NORMAL); diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 881f90017e..fadfd9064f 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -190,12 +190,14 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) /* dependency on the PL handler function */ ObjectAddressSet(referenced, ProcedureRelationId, handlerOid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, handlerOid); /* dependency on the inline handler function, if any */ if (OidIsValid(inlineOid)) { ObjectAddressSet(referenced, ProcedureRelationId, inlineOid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, inlineOid); } /* dependency on the validator function, if any */ @@ -203,6 +205,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) { ObjectAddressSet(referenced, ProcedureRelationId, valOid); add_exact_object_address(&referenced, addrs); + LockNotPinnedObject(ProcedureRelationId, valOid); } record_object_address_dependencies(&myself, addrs, DEPENDENCY_NORMAL); diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 9f28d40466..c0634d0af9 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -1688,6 +1688,8 @@ process_owned_by(Relation seqrel, List *owned_by, bool for_identity) depobject.classId = RelationRelationId; depobject.objectId = RelationGetRelid(seqrel); depobject.objectSubId = 0; + + LockNotPinnedObject(RelationRelationId, RelationGetRelid(tablerel)); recordDependencyOn(&depobject, &refobject, deptype); } diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index 1db3ef69d2..9f0b03388a 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -88,6 +88,7 @@ CreateStatistics(CreateStatsStmt *stmt) bool build_mcv; bool build_expressions; bool requested_type = false; + bool locked_object = false; int i; ListCell *cell; ListCell *cell2; @@ -536,6 +537,12 @@ CreateStatistics(CreateStatsStmt *stmt) for (i = 0; i < nattnums; i++) { ObjectAddressSubSet(parentobject, RelationRelationId, relid, attnums[i]); + + if (!locked_object) + { + LockNotPinnedObject(RelationRelationId, relid); + locked_object = true; + } recordDependencyOn(&myself, &parentobject, DEPENDENCY_AUTO); } @@ -553,6 +560,8 @@ CreateStatistics(CreateStatsStmt *stmt) if (!nattnums) { ObjectAddressSet(parentobject, RelationRelationId, relid); + + LockNotPinnedObject(RelationRelationId, relid); recordDependencyOn(&myself, &parentobject, DEPENDENCY_AUTO); } @@ -573,6 +582,7 @@ CreateStatistics(CreateStatsStmt *stmt) * than the underlying table(s). */ ObjectAddressSet(parentobject, NamespaceRelationId, namespaceId); + LockNotPinnedObject(NamespaceRelationId, namespaceId); recordDependencyOn(&myself, &parentobject, DEPENDENCY_NORMAL); recordDependencyOnOwner(StatisticExtRelationId, statoid, stxowner); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index dbfe0d6b1c..fc7ddf0968 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3419,6 +3419,7 @@ StoreCatalogInheritance1(Oid relationId, Oid parentOid, childobject.objectId = relationId; childobject.objectSubId = 0; + LockNotPinnedObject(RelationRelationId, parentOid); recordDependencyOn(&childobject, &parentobject, child_dependency_type(child_is_partition)); @@ -7342,7 +7343,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, /* * Add needed dependency entries for the new column. */ + LockNotPinnedObject(TypeRelationId, attribute->atttypid); add_column_datatype_dependency(myrelid, newattnum, attribute->atttypid); + LockNotPinnedObject(CollationRelationId, attribute->attcollation); add_column_collation_dependency(myrelid, newattnum, attribute->attcollation); /* @@ -10167,6 +10170,7 @@ addFkRecurseReferenced(List **wqueue, Constraint *fkconstraint, Relation rel, ObjectAddress referenced; ObjectAddressSet(referenced, ConstraintRelationId, parentConstr); + LockNotPinnedObject(ConstraintRelationId, parentConstr); recordDependencyOn(&address, &referenced, DEPENDENCY_INTERNAL); } @@ -10458,8 +10462,11 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel, */ ObjectAddressSet(address, ConstraintRelationId, constrOid); ObjectAddressSet(referenced, ConstraintRelationId, parentConstr); + LockNotPinnedObject(ConstraintRelationId, parentConstr); recordDependencyOn(&address, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, partitionId); + + LockNotPinnedObject(RelationRelationId, partitionId); recordDependencyOn(&address, &referenced, DEPENDENCY_PARTITION_SEC); /* Make all this visible before recursing */ @@ -10960,9 +10967,12 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel) /* Set up partition dependencies for the new constraint */ ObjectAddressSet(address, ConstraintRelationId, constrOid); ObjectAddressSet(referenced, ConstraintRelationId, parentConstrOid); + LockDatabaseObject(ConstraintRelationId, parentConstrOid, 0, AccessShareLock); recordDependencyOn(&address, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, RelationGetRelid(partRel)); + + LockNotPinnedObject(RelationRelationId, RelationGetRelid(partRel)); recordDependencyOn(&address, &referenced, DEPENDENCY_PARTITION_SEC); /* Done with the cloned constraint's tuple */ @@ -13248,7 +13258,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, table_close(attrelation, RowExclusiveLock); /* Install dependencies on new datatype and collation */ + LockNotPinnedObject(TypeRelationId, targettype); add_column_datatype_dependency(RelationGetRelid(rel), attnum, targettype); + LockNotPinnedObject(CollationRelationId, targetcollid); add_column_collation_dependency(RelationGetRelid(rel), attnum, targetcollid); /* @@ -14810,6 +14822,7 @@ ATExecSetAccessMethodNoStorage(Relation rel, Oid newAccessMethodId) */ ObjectAddressSet(relobj, RelationRelationId, reloid); ObjectAddressSet(referenced, AccessMethodRelationId, rd_rel->relam); + LockNotPinnedObject(AccessMethodRelationId, rd_rel->relam); recordDependencyOn(&relobj, &referenced, DEPENDENCY_NORMAL); } else if (OidIsValid(oldAccessMethodId) && @@ -14829,6 +14842,7 @@ ATExecSetAccessMethodNoStorage(Relation rel, Oid newAccessMethodId) OidIsValid(rd_rel->relam)); /* Both are valid, so update the dependency */ + LockNotPinnedObject(AccessMethodRelationId, rd_rel->relam); changeDependencyFor(RelationRelationId, reloid, AccessMethodRelationId, oldAccessMethodId, rd_rel->relam); @@ -16428,6 +16442,7 @@ ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKMODE lockmode) typeobj.classId = TypeRelationId; typeobj.objectId = typeid; typeobj.objectSubId = 0; + LockNotPinnedObject(TypeRelationId, typeid); recordDependencyOn(&tableobj, &typeobj, DEPENDENCY_NORMAL); /* Update pg_class.reloftype */ @@ -17186,14 +17201,17 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid, CatalogTupleUpdate(classRel, &classTup->t_self, classTup); /* Update dependency on schema if caller said so */ - if (hasDependEntry && - changeDependencyFor(RelationRelationId, - relOid, - NamespaceRelationId, - oldNspOid, - newNspOid) != 1) - elog(ERROR, "could not change schema dependency for relation \"%s\"", - NameStr(classForm->relname)); + if (hasDependEntry) + { + LockNotPinnedObject(NamespaceRelationId, newNspOid); + if (changeDependencyFor(RelationRelationId, + relOid, + NamespaceRelationId, + oldNspOid, + newNspOid) != 1) + elog(ERROR, "could not change schema dependency for relation \"%s\"", + NameStr(classForm->relname)); + } } if (!already_done) { diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 170360edda..1250673b16 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -1018,8 +1018,6 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, ((Form_pg_class) GETSTRUCT(tuple))->relhastriggers = true; CatalogTupleUpdate(pgrel, &tuple->t_self, tuple); - - CommandCounterIncrement(); } else CacheInvalidateRelcacheByTuple(tuple); @@ -1027,6 +1025,13 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, heap_freetuple(tuple); table_close(pgrel, RowExclusiveLock); + /* + * CommandCounterIncrement() here to ensure the new trigger entry is + * visible when LockNotPinnedObject() will check its existence before + * recording the dependencies. + */ + CommandCounterIncrement(); + /* * If we're replacing a trigger, flush all the old dependencies before * recording new ones. @@ -1045,6 +1050,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, referenced.classId = ProcedureRelationId; referenced.objectId = funcoid; referenced.objectSubId = 0; + LockNotPinnedObject(ProcedureRelationId, funcoid); recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); if (isInternal && OidIsValid(constraintOid)) @@ -1058,6 +1064,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, referenced.classId = ConstraintRelationId; referenced.objectId = constraintOid; referenced.objectSubId = 0; + LockNotPinnedObject(ConstraintRelationId, constraintOid); recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL); } else @@ -1070,6 +1077,8 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, referenced.classId = RelationRelationId; referenced.objectId = RelationGetRelid(rel); referenced.objectSubId = 0; + + LockNotPinnedObject(RelationRelationId, RelationGetRelid(rel)); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); if (OidIsValid(constrrelid)) @@ -1077,6 +1086,8 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, referenced.classId = RelationRelationId; referenced.objectId = constrrelid; referenced.objectSubId = 0; + + LockNotPinnedObject(RelationRelationId, constrrelid); recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO); } /* Not possible to have an index dependency in this case */ @@ -1091,6 +1102,7 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, referenced.classId = ConstraintRelationId; referenced.objectId = constraintOid; referenced.objectSubId = 0; + LockNotPinnedObject(TriggerRelationId, trigoid); recordDependencyOn(&referenced, &myself, DEPENDENCY_INTERNAL); } @@ -1100,8 +1112,11 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, if (OidIsValid(parentTriggerOid)) { ObjectAddressSet(referenced, TriggerRelationId, parentTriggerOid); + LockNotPinnedObject(TriggerRelationId, parentTriggerOid); recordDependencyOn(&myself, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, RelationGetRelid(rel)); + + LockNotPinnedObject(RelationRelationId, RelationGetRelid(rel)); recordDependencyOn(&myself, &referenced, DEPENDENCY_PARTITION_SEC); } } @@ -1110,12 +1125,19 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString, if (columns != NULL) { int i; + bool locked_object = false; referenced.classId = RelationRelationId; referenced.objectId = RelationGetRelid(rel); for (i = 0; i < ncolumns; i++) { referenced.objectSubId = columns[i]; + + if (!locked_object) + { + LockNotPinnedObject(RelationRelationId, RelationGetRelid(rel)); + locked_object = true; + } recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); } } @@ -1255,9 +1277,12 @@ TriggerSetParentTrigger(Relation trigRel, ObjectAddressSet(depender, TriggerRelationId, childTrigId); ObjectAddressSet(referenced, TriggerRelationId, parentTrigId); + LockNotPinnedObject(TriggerRelationId, parentTrigId); recordDependencyOn(&depender, &referenced, DEPENDENCY_PARTITION_PRI); ObjectAddressSet(referenced, RelationRelationId, childTableId); + + LockNotPinnedObject(RelationRelationId, childTableId); recordDependencyOn(&depender, &referenced, DEPENDENCY_PARTITION_SEC); } else diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c index b7b5019f1e..1b90e187ea 100644 --- a/src/backend/commands/tsearchcmds.c +++ b/src/backend/commands/tsearchcmds.c @@ -214,6 +214,7 @@ DefineTSParser(List *names, List *parameters) namestrcpy(&pname, prsname); values[Anum_pg_ts_parser_prsname - 1] = NameGetDatum(&pname); values[Anum_pg_ts_parser_prsnamespace - 1] = ObjectIdGetDatum(namespaceoid); + LockNotPinnedObject(NamespaceRelationId, namespaceoid); /* * loop over the definition list and extract the information we need. @@ -224,28 +225,48 @@ DefineTSParser(List *names, List *parameters) if (strcmp(defel->defname, "start") == 0) { + Oid procoid; + values[Anum_pg_ts_parser_prsstart - 1] = get_ts_parser_func(defel, Anum_pg_ts_parser_prsstart); + procoid = DatumGetObjectId(values[Anum_pg_ts_parser_prsstart - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else if (strcmp(defel->defname, "gettoken") == 0) { + Oid procoid; + values[Anum_pg_ts_parser_prstoken - 1] = get_ts_parser_func(defel, Anum_pg_ts_parser_prstoken); + procoid = DatumGetObjectId(values[Anum_pg_ts_parser_prstoken - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else if (strcmp(defel->defname, "end") == 0) { + Oid procoid; + values[Anum_pg_ts_parser_prsend - 1] = get_ts_parser_func(defel, Anum_pg_ts_parser_prsend); + procoid = DatumGetObjectId(values[Anum_pg_ts_parser_prsend - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else if (strcmp(defel->defname, "headline") == 0) { + Oid procoid; + values[Anum_pg_ts_parser_prsheadline - 1] = get_ts_parser_func(defel, Anum_pg_ts_parser_prsheadline); + procoid = DatumGetObjectId(values[Anum_pg_ts_parser_prsheadline - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else if (strcmp(defel->defname, "lextypes") == 0) { + Oid procoid; + values[Anum_pg_ts_parser_prslextype - 1] = get_ts_parser_func(defel, Anum_pg_ts_parser_prslextype); + procoid = DatumGetObjectId(values[Anum_pg_ts_parser_prslextype - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else ereport(ERROR, @@ -474,6 +495,10 @@ DefineTSDictionary(List *names, List *parameters) CatalogTupleInsert(dictRel, tup); + /* Lock dependent objects */ + LockNotPinnedObject(NamespaceRelationId, namespaceoid); + LockNotPinnedObject(TSTemplateRelationId, templId); + address = makeDictionaryDependencies(tup); /* Post creation hook for new text search dictionary */ @@ -723,6 +748,7 @@ DefineTSTemplate(List *names, List *parameters) namestrcpy(&dname, tmplname); values[Anum_pg_ts_template_tmplname - 1] = NameGetDatum(&dname); values[Anum_pg_ts_template_tmplnamespace - 1] = ObjectIdGetDatum(namespaceoid); + LockNotPinnedObject(NamespaceRelationId, namespaceoid); /* * loop over the definition list and extract the information we need. @@ -733,15 +759,23 @@ DefineTSTemplate(List *names, List *parameters) if (strcmp(defel->defname, "init") == 0) { + Oid procoid; + values[Anum_pg_ts_template_tmplinit - 1] = get_ts_template_func(defel, Anum_pg_ts_template_tmplinit); nulls[Anum_pg_ts_template_tmplinit - 1] = false; + procoid = DatumGetObjectId(values[Anum_pg_ts_template_tmplinit - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else if (strcmp(defel->defname, "lexize") == 0) { + Oid procoid; + values[Anum_pg_ts_template_tmpllexize - 1] = get_ts_template_func(defel, Anum_pg_ts_template_tmpllexize); nulls[Anum_pg_ts_template_tmpllexize - 1] = false; + procoid = DatumGetObjectId(values[Anum_pg_ts_template_tmpllexize - 1]); + LockNotPinnedObject(ProcedureRelationId, procoid); } else ereport(ERROR, @@ -998,6 +1032,10 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied) values[Anum_pg_ts_config_cfgowner - 1] = ObjectIdGetDatum(GetUserId()); values[Anum_pg_ts_config_cfgparser - 1] = ObjectIdGetDatum(prsOid); + /* Lock dependent objects */ + LockNotPinnedObject(NamespaceRelationId, namespaceoid); + LockNotPinnedObject(TSParserRelationId, prsOid); + tup = heap_form_tuple(cfgRel->rd_att, values, nulls); CatalogTupleInsert(cfgRel, tup); @@ -1063,6 +1101,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied) slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapseqno - 1] = cfgmap->mapseqno; slot[slot_stored_count]->tts_values[Anum_pg_ts_config_map_mapdict - 1] = cfgmap->mapdict; + LockNotPinnedObject(TSDictionaryRelationId, cfgmap->mapdict); ExecStoreVirtualTuple(slot[slot_stored_count]); slot_stored_count++; @@ -1156,9 +1195,13 @@ ObjectAddress AlterTSConfiguration(AlterTSConfigurationStmt *stmt) { HeapTuple tup; + Form_pg_ts_config cfg; Oid cfgId; Relation relMap; ObjectAddress address; + ScanKeyData skey; + SysScanDesc scan; + HeapTuple maptup; /* Find the configuration */ tup = GetTSConfigTuple(stmt->cfgname); @@ -1168,7 +1211,8 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt) errmsg("text search configuration \"%s\" does not exist", NameListToString(stmt->cfgname)))); - cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid; + cfg = (Form_pg_ts_config) GETSTRUCT(tup); + cfgId = cfg->oid; /* must be owner */ if (!object_ownercheck(TSConfigRelationId, cfgId, GetUserId())) @@ -1183,6 +1227,28 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt) else if (stmt->tokentype) DropConfigurationMapping(stmt, tup, relMap); + /* Lock dependent objects */ + + ScanKeyInit(&skey, + Anum_pg_ts_config_map_mapcfg, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(cfgId)); + + scan = systable_beginscan(relMap, TSConfigMapIndexId, true, + NULL, 1, &skey); + + while (HeapTupleIsValid((maptup = systable_getnext(scan)))) + { + Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map) GETSTRUCT(maptup); + + LockNotPinnedObject(TSDictionaryRelationId, cfgmap->mapdict); + } + + systable_endscan(scan); + + LockNotPinnedObject(NamespaceRelationId, cfg->cfgnamespace); + LockNotPinnedObject(TSParserRelationId, cfg->cfgparser); + /* Update dependencies */ makeConfigurationDependencies(tup, true, relMap); @@ -1414,6 +1480,8 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt, repl_val[Anum_pg_ts_config_map_mapdict - 1] = ObjectIdGetDatum(dictNew); repl_repl[Anum_pg_ts_config_map_mapdict - 1] = true; + LockNotPinnedObject(TSDictionaryRelationId, dictNew); + newtup = heap_modify_tuple(maptup, RelationGetDescr(relMap), repl_val, repl_null, repl_repl); @@ -1456,6 +1524,9 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt, slot[slotCount]->tts_values[Anum_pg_ts_config_map_mapseqno - 1] = Int32GetDatum(j + 1); slot[slotCount]->tts_values[Anum_pg_ts_config_map_mapdict - 1] = ObjectIdGetDatum(dictIds[j]); + /* Lock dependent objects */ + LockNotPinnedObject(TSDictionaryRelationId, dictIds[j]); + ExecStoreVirtualTuple(slot[slotCount]); slotCount++; diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 2a1e713335..9febaa24a7 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -1794,6 +1794,7 @@ makeRangeConstructors(const char *name, Oid namespace, * that they go away silently when the type is dropped. Note that * pg_dump depends on this choice to avoid dumping the constructors. */ + LockNotPinnedObject(TypeRelationId, rangeOid); recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL); } } @@ -1859,6 +1860,7 @@ makeMultirangeConstructors(const char *name, Oid namespace, * that they go away silently when the type is dropped. Note that pg_dump * depends on this choice to avoid dumping the constructors. */ + LockNotPinnedObject(TypeRelationId, multirangeOid); recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL); pfree(argtypes); @@ -2672,6 +2674,45 @@ AlterDomainDefault(List *names, Node *defaultRaw) CatalogTupleUpdate(rel, &tup->t_self, newtuple); + /* Lock dependent objects */ + typTup = (Form_pg_type) GETSTRUCT(newtuple); + + if (OidIsValid(typTup->typnamespace)) + LockNotPinnedObject(NamespaceRelationId, typTup->typnamespace); + + if (OidIsValid(typTup->typinput)) + LockNotPinnedObject(ProcedureRelationId, typTup->typinput); + + if (OidIsValid(typTup->typoutput)) + LockNotPinnedObject(ProcedureRelationId, typTup->typoutput); + + if (OidIsValid(typTup->typreceive)) + LockNotPinnedObject(ProcedureRelationId, typTup->typreceive); + + if (OidIsValid(typTup->typsend)) + LockNotPinnedObject(ProcedureRelationId, typTup->typsend); + + if (OidIsValid(typTup->typmodin)) + LockNotPinnedObject(ProcedureRelationId, typTup->typmodin); + + if (OidIsValid(typTup->typmodout)) + LockNotPinnedObject(ProcedureRelationId, typTup->typmodout); + + if (OidIsValid(typTup->typanalyze)) + LockNotPinnedObject(ProcedureRelationId, typTup->typanalyze); + + if (OidIsValid(typTup->typsubscript)) + LockNotPinnedObject(ProcedureRelationId, typTup->typsubscript); + + if (OidIsValid(typTup->typbasetype)) + LockNotPinnedObject(TypeRelationId, typTup->typbasetype); + + if (OidIsValid(typTup->typcollation)) + LockNotPinnedObject(CollationRelationId, typTup->typcollation); + + if (OidIsValid(typTup->typelem)) + LockNotPinnedObject(TypeRelationId, typTup->typelem); + /* Rebuild dependencies */ GenerateTypeDependencies(newtuple, rel, @@ -4276,10 +4317,13 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, if (oldNspOid != nspOid && (isCompositeType || typform->typtype != TYPTYPE_COMPOSITE) && !isImplicitArray) + { + LockNotPinnedObject(NamespaceRelationId, nspOid); if (changeDependencyFor(TypeRelationId, typeOid, NamespaceRelationId, oldNspOid, nspOid) != 1) elog(ERROR, "could not change schema dependency for type \"%s\"", format_type_be(typeOid)); + } InvokeObjectPostAlterHook(TypeRelationId, typeOid, 0); @@ -4571,6 +4615,7 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray, SysScanDesc scan; ScanKeyData key[1]; HeapTuple domainTup; + Form_pg_type typeForm; /* Since this function recurses, it could be driven to stack overflow */ check_stack_depth(); @@ -4619,6 +4664,45 @@ AlterTypeRecurse(Oid typeOid, bool isImplicitArray, newtup = heap_modify_tuple(tup, RelationGetDescr(catalog), values, nulls, replaces); + /* Lock dependent objects */ + typeForm = (Form_pg_type) GETSTRUCT(newtup); + + if (OidIsValid(typeForm->typnamespace)) + LockNotPinnedObject(NamespaceRelationId, typeForm->typnamespace); + + if (OidIsValid(typeForm->typinput)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typinput); + + if (OidIsValid(typeForm->typoutput)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typoutput); + + if (OidIsValid(typeForm->typreceive)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typreceive); + + if (OidIsValid(typeForm->typsend)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typsend); + + if (OidIsValid(typeForm->typmodin)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typmodin); + + if (OidIsValid(typeForm->typmodout)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typmodout); + + if (OidIsValid(typeForm->typanalyze)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typanalyze); + + if (OidIsValid(typeForm->typsubscript)) + LockNotPinnedObject(ProcedureRelationId, typeForm->typsubscript); + + if (OidIsValid(typeForm->typbasetype)) + LockNotPinnedObject(TypeRelationId, typeForm->typbasetype); + + if (OidIsValid(typeForm->typcollation)) + LockNotPinnedObject(CollationRelationId, typeForm->typcollation); + + if (OidIsValid(typeForm->typelem)) + LockNotPinnedObject(TypeRelationId, typeForm->typelem); + CatalogTupleUpdate(catalog, &newtup->t_self, newtup); /* Rebuild dependencies for this type */ diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index 6cc9a8d8bf..c930eca262 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -155,6 +155,7 @@ InsertRule(const char *rulname, referenced.objectId = eventrel_oid; referenced.objectSubId = 0; + LockNotPinnedObject(RelationRelationId, eventrel_oid); recordDependencyOn(&myself, &referenced, (evtype == CMD_SELECT) ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); diff --git a/src/backend/utils/errcodes.txt b/src/backend/utils/errcodes.txt index 3250d539e1..60e8539fe3 100644 --- a/src/backend/utils/errcodes.txt +++ b/src/backend/utils/errcodes.txt @@ -271,6 +271,7 @@ Section: Class 28 - Invalid Authorization Specification Section: Class 2B - Dependent Privilege Descriptors Still Exist 2B000 E ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST dependent_privilege_descriptors_still_exist +2BP02 E ERRCODE_DEPENDENT_OBJECTS_DOES_NOT_EXIST dependent_objects_does_not_exist 2BP01 E ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST dependent_objects_still_exist Section: Class 2D - Invalid Transaction Termination diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h index 6908ca7180..0546bcbe16 100644 --- a/src/include/catalog/dependency.h +++ b/src/include/catalog/dependency.h @@ -101,6 +101,8 @@ typedef struct ObjectAddresses ObjectAddresses; /* in dependency.c */ extern void AcquireDeletionLock(const ObjectAddress *object, int flags); +extern void LockNotPinnedObjectById(const ObjectAddress *object); +extern void LockNotPinnedObject(Oid classid, Oid objid); extern void ReleaseDeletionLock(const ObjectAddress *object); @@ -172,6 +174,7 @@ extern long changeDependenciesOf(Oid classId, Oid oldObjectId, extern long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId); +extern bool isObjectPinned(const ObjectAddress *object); extern Oid getExtensionOfObject(Oid classId, Oid objectId); extern List *getAutoExtensionsOfObject(Oid classId, Oid objectId); diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h index 3a70d80e32..56f746264b 100644 --- a/src/include/catalog/objectaddress.h +++ b/src/include/catalog/objectaddress.h @@ -53,6 +53,7 @@ extern void check_object_ownership(Oid roleid, Node *object, Relation relation); extern Oid get_object_namespace(const ObjectAddress *address); +extern bool ObjectByIdExist(const ObjectAddress *address); extern bool is_objectclass_supported(Oid class_id); extern const char *get_object_class_descr(Oid class_id); diff --git a/src/test/isolation/expected/test_dependencies_locks.out b/src/test/isolation/expected/test_dependencies_locks.out new file mode 100644 index 0000000000..9b645d7aa5 --- /dev/null +++ b/src/test/isolation/expected/test_dependencies_locks.out @@ -0,0 +1,129 @@ +Parsed test spec with 2 sessions + +starting permutation: s1_begin s1_create_function_in_schema s2_drop_schema s1_commit +step s1_begin: BEGIN; +step s1_create_function_in_schema: CREATE FUNCTION testschema.foo() RETURNS int AS 'select 1' LANGUAGE sql; +step s2_drop_schema: DROP SCHEMA testschema; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_schema: <... completed> +ERROR: cannot drop schema testschema because other objects depend on it + +starting permutation: s2_begin s2_drop_schema s1_create_function_in_schema s2_commit +step s2_begin: BEGIN; +step s2_drop_schema: DROP SCHEMA testschema; +step s1_create_function_in_schema: CREATE FUNCTION testschema.foo() RETURNS int AS 'select 1' LANGUAGE sql; <waiting ...> +step s2_commit: COMMIT; +step s1_create_function_in_schema: <... completed> +ERROR: schema testschema does not exist + +starting permutation: s1_begin s1_alter_function_schema s2_drop_alterschema s1_commit +step s1_begin: BEGIN; +step s1_alter_function_schema: ALTER FUNCTION public.falter() SET SCHEMA alterschema; +step s2_drop_alterschema: DROP SCHEMA alterschema; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_alterschema: <... completed> +ERROR: cannot drop schema alterschema because other objects depend on it + +starting permutation: s2_begin s2_drop_alterschema s1_alter_function_schema s2_commit +step s2_begin: BEGIN; +step s2_drop_alterschema: DROP SCHEMA alterschema; +step s1_alter_function_schema: ALTER FUNCTION public.falter() SET SCHEMA alterschema; <waiting ...> +step s2_commit: COMMIT; +step s1_alter_function_schema: <... completed> +ERROR: schema alterschema does not exist + +starting permutation: s1_begin s1_create_function_with_argtype s2_drop_foo_type s1_commit +step s1_begin: BEGIN; +step s1_create_function_with_argtype: CREATE FUNCTION fooargtype(num foo) RETURNS int AS 'select 1' LANGUAGE sql; +step s2_drop_foo_type: DROP TYPE public.foo; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_foo_type: <... completed> +ERROR: cannot drop type foo because other objects depend on it + +starting permutation: s2_begin s2_drop_foo_type s1_create_function_with_argtype s2_commit +step s2_begin: BEGIN; +step s2_drop_foo_type: DROP TYPE public.foo; +step s1_create_function_with_argtype: CREATE FUNCTION fooargtype(num foo) RETURNS int AS 'select 1' LANGUAGE sql; <waiting ...> +step s2_commit: COMMIT; +step s1_create_function_with_argtype: <... completed> +ERROR: type foo does not exist + +starting permutation: s1_begin s1_create_function_with_rettype s2_drop_foo_rettype s1_commit +step s1_begin: BEGIN; +step s1_create_function_with_rettype: CREATE FUNCTION footrettype() RETURNS id LANGUAGE sql RETURN 1; +step s2_drop_foo_rettype: DROP DOMAIN id; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_foo_rettype: <... completed> +ERROR: cannot drop type id because other objects depend on it + +starting permutation: s2_begin s2_drop_foo_rettype s1_create_function_with_rettype s2_commit +step s2_begin: BEGIN; +step s2_drop_foo_rettype: DROP DOMAIN id; +step s1_create_function_with_rettype: CREATE FUNCTION footrettype() RETURNS id LANGUAGE sql RETURN 1; <waiting ...> +step s2_commit: COMMIT; +step s1_create_function_with_rettype: <... completed> +ERROR: type id does not exist + +starting permutation: s1_begin s1_create_function_with_function s2_drop_function_f s1_commit +step s1_begin: BEGIN; +step s1_create_function_with_function: CREATE FUNCTION foofunc() RETURNS int LANGUAGE SQL RETURN f() + 1; +step s2_drop_function_f: DROP FUNCTION f(); <waiting ...> +step s1_commit: COMMIT; +step s2_drop_function_f: <... completed> +ERROR: cannot drop function f() because other objects depend on it + +starting permutation: s2_begin s2_drop_function_f s1_create_function_with_function s2_commit +step s2_begin: BEGIN; +step s2_drop_function_f: DROP FUNCTION f(); +step s1_create_function_with_function: CREATE FUNCTION foofunc() RETURNS int LANGUAGE SQL RETURN f() + 1; <waiting ...> +step s2_commit: COMMIT; +step s1_create_function_with_function: <... completed> +ERROR: function f() does not exist + +starting permutation: s1_begin s1_create_domain_with_domain s2_drop_domain_id s1_commit +step s1_begin: BEGIN; +step s1_create_domain_with_domain: CREATE DOMAIN idid as id; +step s2_drop_domain_id: DROP DOMAIN id; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_domain_id: <... completed> +ERROR: cannot drop type id because other objects depend on it + +starting permutation: s2_begin s2_drop_domain_id s1_create_domain_with_domain s2_commit +step s2_begin: BEGIN; +step s2_drop_domain_id: DROP DOMAIN id; +step s1_create_domain_with_domain: CREATE DOMAIN idid as id; <waiting ...> +step s2_commit: COMMIT; +step s1_create_domain_with_domain: <... completed> +ERROR: type id does not exist + +starting permutation: s1_begin s1_create_table_with_type s2_drop_footab_type s1_commit +step s1_begin: BEGIN; +step s1_create_table_with_type: CREATE TABLE tabtype(a footab); +step s2_drop_footab_type: DROP TYPE public.footab; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_footab_type: <... completed> +ERROR: cannot drop type footab because other objects depend on it + +starting permutation: s2_begin s2_drop_footab_type s1_create_table_with_type s2_commit +step s2_begin: BEGIN; +step s2_drop_footab_type: DROP TYPE public.footab; +step s1_create_table_with_type: CREATE TABLE tabtype(a footab); <waiting ...> +step s2_commit: COMMIT; +step s1_create_table_with_type: <... completed> +ERROR: type footab does not exist + +starting permutation: s1_begin s1_create_server_with_fdw_wrapper s2_drop_fdw_wrapper s1_commit +step s1_begin: BEGIN; +step s1_create_server_with_fdw_wrapper: CREATE SERVER srv_fdw_wrapper FOREIGN DATA WRAPPER fdw_wrapper; +step s2_drop_fdw_wrapper: DROP FOREIGN DATA WRAPPER fdw_wrapper RESTRICT; <waiting ...> +step s1_commit: COMMIT; +step s2_drop_fdw_wrapper: <... completed> +ERROR: cannot drop foreign-data wrapper fdw_wrapper because other objects depend on it + +starting permutation: s2_begin s2_drop_fdw_wrapper s1_create_server_with_fdw_wrapper s2_commit +step s2_begin: BEGIN; +step s2_drop_fdw_wrapper: DROP FOREIGN DATA WRAPPER fdw_wrapper RESTRICT; +step s1_create_server_with_fdw_wrapper: CREATE SERVER srv_fdw_wrapper FOREIGN DATA WRAPPER fdw_wrapper; <waiting ...> +step s2_commit: COMMIT; +step s1_create_server_with_fdw_wrapper: <... completed> +ERROR: foreign-data wrapper fdw_wrapper does not exist diff --git a/src/test/isolation/isolation_schedule b/src/test/isolation/isolation_schedule index 6da98cffac..ef6a7075bc 100644 --- a/src/test/isolation/isolation_schedule +++ b/src/test/isolation/isolation_schedule @@ -117,3 +117,4 @@ test: serializable-parallel-2 test: serializable-parallel-3 test: matview-write-skew test: lock-nowait +test: test_dependencies_locks diff --git a/src/test/isolation/specs/test_dependencies_locks.spec b/src/test/isolation/specs/test_dependencies_locks.spec new file mode 100644 index 0000000000..5d04dfe9dc --- /dev/null +++ b/src/test/isolation/specs/test_dependencies_locks.spec @@ -0,0 +1,89 @@ +setup +{ + CREATE SCHEMA testschema; + CREATE SCHEMA alterschema; + CREATE TYPE public.foo as enum ('one', 'two'); + CREATE TYPE public.footab as enum ('three', 'four'); + CREATE DOMAIN id AS int; + CREATE FUNCTION f() RETURNS int LANGUAGE SQL RETURN 1; + CREATE FUNCTION public.falter() RETURNS int LANGUAGE SQL RETURN 1; + CREATE FOREIGN DATA WRAPPER fdw_wrapper; +} + +teardown +{ + DROP FUNCTION IF EXISTS testschema.foo(); + DROP FUNCTION IF EXISTS fooargtype(num foo); + DROP FUNCTION IF EXISTS footrettype(); + DROP FUNCTION IF EXISTS foofunc(); + DROP FUNCTION IF EXISTS public.falter(); + DROP FUNCTION IF EXISTS alterschema.falter(); + DROP DOMAIN IF EXISTS idid; + DROP SERVER IF EXISTS srv_fdw_wrapper; + DROP TABLE IF EXISTS tabtype; + DROP SCHEMA IF EXISTS testschema; + DROP SCHEMA IF EXISTS alterschema; + DROP TYPE IF EXISTS public.foo; + DROP TYPE IF EXISTS public.footab; + DROP DOMAIN IF EXISTS id; + DROP FUNCTION IF EXISTS f(); + DROP FOREIGN DATA WRAPPER IF EXISTS fdw_wrapper; +} + +session "s1" + +step "s1_begin" { BEGIN; } +step "s1_create_function_in_schema" { CREATE FUNCTION testschema.foo() RETURNS int AS 'select 1' LANGUAGE sql; } +step "s1_create_function_with_argtype" { CREATE FUNCTION fooargtype(num foo) RETURNS int AS 'select 1' LANGUAGE sql; } +step "s1_create_function_with_rettype" { CREATE FUNCTION footrettype() RETURNS id LANGUAGE sql RETURN 1; } +step "s1_create_function_with_function" { CREATE FUNCTION foofunc() RETURNS int LANGUAGE SQL RETURN f() + 1; } +step "s1_alter_function_schema" { ALTER FUNCTION public.falter() SET SCHEMA alterschema; } +step "s1_create_domain_with_domain" { CREATE DOMAIN idid as id; } +step "s1_create_table_with_type" { CREATE TABLE tabtype(a footab); } +step "s1_create_server_with_fdw_wrapper" { CREATE SERVER srv_fdw_wrapper FOREIGN DATA WRAPPER fdw_wrapper; } +step "s1_commit" { COMMIT; } + +session "s2" + +step "s2_begin" { BEGIN; } +step "s2_drop_schema" { DROP SCHEMA testschema; } +step "s2_drop_alterschema" { DROP SCHEMA alterschema; } +step "s2_drop_foo_type" { DROP TYPE public.foo; } +step "s2_drop_foo_rettype" { DROP DOMAIN id; } +step "s2_drop_footab_type" { DROP TYPE public.footab; } +step "s2_drop_function_f" { DROP FUNCTION f(); } +step "s2_drop_domain_id" { DROP DOMAIN id; } +step "s2_drop_fdw_wrapper" { DROP FOREIGN DATA WRAPPER fdw_wrapper RESTRICT; } +step "s2_commit" { COMMIT; } + +# function - schema +permutation "s1_begin" "s1_create_function_in_schema" "s2_drop_schema" "s1_commit" +permutation "s2_begin" "s2_drop_schema" "s1_create_function_in_schema" "s2_commit" + +# alter function - schema +permutation "s1_begin" "s1_alter_function_schema" "s2_drop_alterschema" "s1_commit" +permutation "s2_begin" "s2_drop_alterschema" "s1_alter_function_schema" "s2_commit" + +# function - argtype +permutation "s1_begin" "s1_create_function_with_argtype" "s2_drop_foo_type" "s1_commit" +permutation "s2_begin" "s2_drop_foo_type" "s1_create_function_with_argtype" "s2_commit" + +# function - rettype +permutation "s1_begin" "s1_create_function_with_rettype" "s2_drop_foo_rettype" "s1_commit" +permutation "s2_begin" "s2_drop_foo_rettype" "s1_create_function_with_rettype" "s2_commit" + +# function - function +permutation "s1_begin" "s1_create_function_with_function" "s2_drop_function_f" "s1_commit" +permutation "s2_begin" "s2_drop_function_f" "s1_create_function_with_function" "s2_commit" + +# domain - domain +permutation "s1_begin" "s1_create_domain_with_domain" "s2_drop_domain_id" "s1_commit" +permutation "s2_begin" "s2_drop_domain_id" "s1_create_domain_with_domain" "s2_commit" + +# table - type +permutation "s1_begin" "s1_create_table_with_type" "s2_drop_footab_type" "s1_commit" +permutation "s2_begin" "s2_drop_footab_type" "s1_create_table_with_type" "s2_commit" + +# server - foreign data wrapper +permutation "s1_begin" "s1_create_server_with_fdw_wrapper" "s2_drop_fdw_wrapper" "s1_commit" +permutation "s2_begin" "s2_drop_fdw_wrapper" "s1_create_server_with_fdw_wrapper" "s2_commit" diff --git a/src/test/modules/test_oat_hooks/expected/alter_table.out b/src/test/modules/test_oat_hooks/expected/alter_table.out index 8cbacca2c9..df8d276dfc 100644 --- a/src/test/modules/test_oat_hooks/expected/alter_table.out +++ b/src/test/modules/test_oat_hooks/expected/alter_table.out @@ -37,6 +37,8 @@ NOTICE: in object access: superuser attempting create (subId=0x0) [internal] NOTICE: in object access: superuser finished create (subId=0x0) [internal] NOTICE: in object access: superuser attempting create (subId=0x0) [internal] NOTICE: in object access: superuser finished create (subId=0x0) [internal] +NOTICE: in object access: superuser attempting namespace search (subId=0x0) [no report on violation, allowed] +NOTICE: in object access: superuser finished namespace search (subId=0x0) [no report on violation, allowed] NOTICE: in process utility: superuser finished CREATE TABLE CREATE RULE test_oat_notify AS ON UPDATE TO test_oat_schema.test_oat_tab @@ -62,8 +64,6 @@ BEGIN END IF; END; $$; NOTICE: in process utility: superuser attempting CREATE FUNCTION -NOTICE: in object access: superuser attempting namespace search (subId=0x0) [no report on violation, allowed] -NOTICE: in object access: superuser finished namespace search (subId=0x0) [no report on violation, allowed] NOTICE: in object access: superuser attempting create (subId=0x0) [explicit] NOTICE: in object access: superuser finished create (subId=0x0) [explicit] NOTICE: in process utility: superuser finished CREATE FUNCTION diff --git a/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out b/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out index effdc49145..da6d931994 100644 --- a/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out +++ b/src/test/modules/test_oat_hooks/expected/test_oat_hooks.out @@ -86,6 +86,8 @@ NOTICE: in object access: superuser attempting create (subId=0x0) [internal] NOTICE: in object access: superuser finished create (subId=0x0) [internal] NOTICE: in object access: superuser attempting create (subId=0x0) [internal] NOTICE: in object access: superuser finished create (subId=0x0) [internal] +NOTICE: in object access: superuser attempting namespace search (subId=0x0) [no report on violation, allowed] +NOTICE: in object access: superuser finished namespace search (subId=0x0) [no report on violation, allowed] NOTICE: in process utility: superuser finished CREATE TABLE CREATE INDEX regress_test_table_t_idx ON regress_test_table (t); NOTICE: in process utility: superuser attempting CREATE INDEX diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 673361e840..c2115ea601 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -2867,11 +2867,12 @@ begin; alter table alterlock2 add constraint alterlock2nv foreign key (f1) references alterlock (f1) NOT VALID; select * from my_locks order by 1; - relname | max_lockmode -------------+----------------------- - alterlock | ShareRowExclusiveLock - alterlock2 | ShareRowExclusiveLock -(2 rows) + relname | max_lockmode +----------------+----------------------- + alterlock | ShareRowExclusiveLock + alterlock2 | ShareRowExclusiveLock + alterlock_pkey | AccessShareLock +(3 rows) commit; begin; -- 2.34.1 --Bj+x/cSHj0rO0bhZ-- ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
* [PATCH v6a 2/5] gha: Andres' revisions @ 2026-06-01 19:09 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 249+ messages in thread From: Andres Freund @ 2026-06-01 19:09 UTC (permalink / raw) --- .github/workflows/postgresql-ci.yml | 834 +++++++++++++++------------- 1 file changed, 447 insertions(+), 387 deletions(-) diff --git a/.github/workflows/postgresql-ci.yml b/.github/workflows/postgresql-ci.yml index a7ef0bee94d..e2795ca0ffb 100644 --- a/.github/workflows/postgresql-ci.yml +++ b/.github/workflows/postgresql-ci.yml @@ -4,6 +4,7 @@ name: GitHub Actions CI on: push: + # FIXME: Should we also run on PRs? # Restrict GITHUB_TOKEN to the minimum the jobs need: reading repo # contents during checkout. @@ -13,6 +14,7 @@ permissions: concurrency: group: ${{ github.workflow }}-${{ github.ref }} # Never cancel in-progress runs on master to ensure all commits are tested. + # FIXME: Should also not cancel REL_XY_STABLE cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} env: @@ -20,9 +22,19 @@ env: # concurrent jobs and retrying older runs have a chance of working. CLONE_DEPTH: 500 + # At the moment all jobs use 4vcore runners, and none seems to benefit from + # increasing concurrency further. + BUILD_JOBS: 4 + + # It's possible that some jobs benefit from an increased test concurrency, + # but a default of 4 is a safe bet. Individual jobs can override. + TEST_JOBS: 4 + CCACHE_MAXSIZE: "250M" + CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # check target for the autoconf builds + # Check target for the autoconf builds. Can be set to e.g. check to only + # only test the main regression tests. CHECK: check-world PROVE_FLAGS=--timer CHECKFLAGS: -Otarget @@ -30,6 +42,11 @@ env: # errors/warnings in one place. MBUILD_TARGET: all testprep MTEST_ARGS: --print-errorlogs --no-rebuild -C build + + # Can be set to a non-empty value to run a limited set of tests + # (e.g. --suite regress to only run the main regression tests). + MTEST_TARGET: + PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests TEMP_CONFIG: ${{ github.workspace }}/src/tools/ci/pg_ci_base.conf PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth @@ -79,20 +96,16 @@ env: --with-uuid=ossp --with-zstd - # Debian Trixie container image used by all Linux jobs. Built by + # Debian Trixie containers used by all Linux jobs. Built by # 'https://github.com/anarazel/pg-vm-images/';. - LINUX_CI_IMAGE: us-docker.pkg.dev/pg-ci-images/ci/linux_debian_trixie_ci:latest + CONTAINER_REPO: ghcr.io/anarazel/pg-vm-images/gha_main + CONTAINER_LINUX_CI: linux_debian_trixie_ci:latest + CONTAINER_LINUX_CI_DOCS: linux_debian_trixie_ci_docs:latest # The full set of OS / job selectors recognized by the `ci-os-only:` # commit-message directive parsed in the `setup` job below. CI_OS_ONLY_JOBS: "linux macos windows mingw compilerwarnings sanitycheck" - _LOG_PATHS: &log_paths | - build*/testrun/**/*.log - build*/testrun/**/*.diffs - build*/testrun/**/regress_log_* - build*/meson-logs/*.txt - jobs: # Parse "ci-os-only: ..." from the commit message and expose flags @@ -111,14 +124,26 @@ jobs: # Re-export workflow-level env vars that other jobs need to reference # from contexts (e.g. `jobs.<id>.container.image`) where the `env` # context is not available. - linux_ci_image: ${{ env.LINUX_CI_IMAGE }} + container_linux_ci: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI }} + container_linux_ci_docs: ${{ env.CONTAINER_REPO }}/${{ env.CONTAINER_LINUX_CI_DOCS }} steps: + # Anchor reused by other jobs further down. GitHub Actions supports YAML + # anchors/aliases but not merge keys, so the alias copies the whole step + # verbatim. The anchor is resolved at YAML parse time, so the alias + # keeps working even if this job were to be skipped at runtime. + - &nix_sysinfo_step + name: sysinfo + run: | + id + uname -a + ulimit -a -H && ulimit -a -S + env + - id: os env: MSG: ${{ github.event.head_commit.message }} shell: bash run: | - set -e all_os=${CI_OS_ONLY_JOBS} if printf '%s\n' "$MSG" | grep -qE '^ci-os-only: '; then sel=$(printf '%s\n' "$MSG" | sed -n 's/^ci-os-only: //p' | head -n 1) @@ -145,199 +170,22 @@ jobs: sanity-check: name: SanityCheck needs: setup - if: needs.setup.outputs.sanitycheck == 'true' + if: | + !cancelled() && + needs.setup.outputs.sanitycheck == 'true' runs-on: ubuntu-latest timeout-minutes: 15 - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + container: &linux_ci_container + image: ${{ needs.setup.outputs.container_linux_ci }} + + # Options passed to all linux containers. Not all of the jobs need + # all of them, but it's easier to just define them centrally. + # # --privileged is needed so the prepare step can write to sysctls # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern. - options: --privileged - env: - BUILD_JOBS: 8 - TEST_JOBS: 8 - CCACHE_DIR: ${{ github.workspace }}/ccache_dir - # no options enabled, should be small - CCACHE_MAXSIZE: "150M" - steps: - # Anchor reused by other jobs further down. GitHub Actions supports - # YAML anchors/aliases but not merge keys, so the alias copies the - # whole step verbatim. The anchor is resolved at YAML parse time, so the - # alias keeps working even if this job is skipped at runtime. - - &checkout_step - uses: actions/checkout@v6 - with: - fetch-depth: ${{ env.CLONE_DEPTH }} - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-sanitycheck-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-sanitycheck-${{ github.ref_name }}- - ccache-sanitycheck- - - - name: Prepare workspace - run: | - whoami - useradd -m postgres - chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" - - - name: Configure - run: | - su postgres <<-'EOF' - set -e - meson setup \ - --buildtype=debug \ - --auto-features=disabled \ - -Ddefault_library=shared \ - -Dtap_tests=enabled \ - build - EOF - - - name: Build - run: | - su postgres <<EOF - set -e - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - EOF - - # Run a minimal set of tests. The main regression tests take too long - # for this purpose. For now this is a random quick pg_regress style - # test, and a tap test that exercises both a frontend binary and the - # backend. - - name: Test - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - meson test ${MTEST_ARGS} --suite setup - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} \ - cube/regress pg_ctl/001_start_stop - EOF - - - name: Core backtraces - if: failure() - run: | - mkdir -m 770 /tmp/cores - find / -maxdepth 1 -type f -name 'core*' -exec mv '{}' /tmp/cores/ \; - src/tools/ci/cores_backtrace.sh linux /tmp/cores - - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: sanitycheck-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore - - - # Build & test postgres on Linux in three configurations. - # - # Autoconf: - # - Uses address sanitizer (sanitizer failures are typically printed in - # the server log) - # - Configures postgres with a small segment size - # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range - # - # Meson: - # - Test both 64- and 32-bit builds - # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures - # are typically printed in the server log) - # - Uses io_method=io_uring - # - Uses meson feature autodetection - # - 32-bit build tests with LANG=C to give ICU some buildfarm-uncovered - # coverage. Also, newer Python insists on changing LC_CTYPE away from C, - # prevent that with PYTHONCOERCECLOCALE. - # - # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes - # print_stacktraces=1,verbosity=2, duh - # detect_leaks=0: too many uninteresting leak errors in short-lived binaries - linux: - name: Linux - ${{ matrix.name }} - needs: [setup, sanity-check] - if: | - !cancelled() && - needs.setup.outputs.linux == 'true' && - needs.sanity-check.result != 'failure' - runs-on: ubuntu-latest - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - include: - - name: Autoconf - slug: autoconf - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=address - pg_test_pg_combinebackup_mode: '--copy-file-range' - configure: | - ./configure \ - --enable-cassert --enable-injection-points --enable-debug \ - --enable-tap-tests --enable-nls \ - --with-segsize-blocks=6 \ - --with-libnuma \ - --with-liburing \ - ${LINUX_CONFIGURE_FEATURES} \ - CLANG="ccache clang" - build: | - make -s -j${BUILD_JOBS} world-bin - test: | - make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} - logs_paths: | - **/*.log - **/*.diffs - **/regress_log_* - - - name: Meson (64-bit) - slug: meson-64 - cc: ccache gcc - cxx: ccache g++ - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - -Dllvm=enabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - - - name: Meson (32-bit) - slug: meson-32 - cc: ccache gcc -m32 - cxx: ccache g++ -m32 - sanitizer_flags: -fsanitize=alignment,undefined - pg_test_initdb_extra_opts: '-c io_method=io_uring' - configure: | - meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ - -Duuid=e2fs \ - --buildtype=debug \ - --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ - -DPERL=perl5.40-i386-linux-gnu \ - -Dlibnuma=disabled \ - build - build: | - ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} - ninja -C build -t missingdeps - test: | - PYTHONCOERCECLOCALE=0 LANG=C \ - meson test ${MTEST_ARGS} -C build --num-processes ${TEST_JOBS} - logs_paths: *log_paths - container: - image: ${{ needs.setup.outputs.linux_ci_image }} + # set kernel.core_pattern and (for the meson entries) to flip + # kernel.io_uring_disabled (default 2 on recent GH runner kernels). + # # Share the host PID + IPC namespaces. 017_shm.pl rapidly creates, # kill9's, and restarts postgres; with the container's small PID # space a new postgres can recycle the dead postmaster's PID before @@ -347,46 +195,36 @@ jobs: # # --ulimit raises memlock and core dump size. Memlock is needed for # running the AIO tests. - # - # --privileged is needed so the prepare step can write to sysctls - # under /proc/sys (it's mounted read-only without it). We use it to - # set kernel.core_pattern and (for the meson entries) to flip - # kernel.io_uring_disabled (default 2 on recent GH runner kernels). - options: --pid=host --ipc=host --ulimit memlock=-1:-1 --privileged + options: &linux_container_options | + --privileged --pid=host --ipc=host --ulimit memlock=-1:-1 env: - BUILD_JOBS: 4 - TEST_JOBS: 8 - CCACHE_DIR: /tmp/ccache_dir - DEBUGINFOD_URLS: "https://debuginfod.debian.net"; - - UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 - ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0:detect_stack_use_after_return=0 - CFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - CXXFLAGS: -Og -ggdb -fno-sanitize-recover=all ${{ matrix.sanitizer_flags }} - LDFLAGS: ${{ matrix.sanitizer_flags }} - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - PG_TEST_INITDB_EXTRA_OPTS: ${{ matrix.pg_test_initdb_extra_opts }} - PG_TEST_PG_COMBINEBACKUP_MODE: ${{ matrix.pg_test_pg_combinebackup_mode }} + # no options enabled, should be small + CCACHE_MAXSIZE: "150M" steps: - - *checkout_step + - *nix_sysinfo_step - - name: Restore ccache - uses: actions/cache@v5 + - &checkout_step + uses: actions/checkout@v6 + with: + fetch-depth: ${{ env.CLONE_DEPTH }} + + - &ccache_restore_step + name: Restore ccache + id: ccache_restore + uses: actions/cache/restore@v5 with: path: ${{ env.CCACHE_DIR }} - key: ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}-${{ github.run_id }} + key: &ccache_key | + ccache-${{ github.job }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }} restore-keys: | - ccache-linux-${{ matrix.slug }}-${{ github.ref_name }}- - ccache-linux-${{ matrix.slug }}- + ccache-${{ github.job }}-${{ github.ref_name }}- + ccache-${{ github.job }}- - - name: Prepare workspace + - &linux_prepare_workspace + name: Prepare workspace run: | useradd -m postgres chown -R postgres:postgres . - mkdir -p "$CCACHE_DIR" - chown -R postgres:postgres "$CCACHE_DIR" mkdir -m 770 /tmp/cores chown root:postgres /tmp/cores sysctl kernel.core_pattern='/tmp/cores/%e-%s-%p.core' @@ -400,41 +238,283 @@ jobs: 127.0.0.3 pg-loadbalancetest EOF + # By using a shell that includes su, the run commands themselves get + # simpler. As there are quite a few commands that need to use su... - name: Configure + shell: &su_postgres_shell | + su postgres -c "bash --noprofile --norc -eo pipefail {0}" run: | - su postgres <<EOF - set -e - ${{ matrix.configure }} - EOF + meson setup \ + --buildtype=debug \ + --auto-features=disabled \ + -Ddefault_library=shared \ + -Dtap_tests=enabled \ + build - name: Build - run: | - su postgres <<EOF - set -e - ${{ matrix.build }} - EOF + shell: *su_postgres_shell + run: &ninja_build_command | + ninja -C build -j${{env.BUILD_JOBS}} ${{env.MBUILD_TARGET}} + ninja -C build -t missingdeps - - name: Test world - run: | - su postgres <<EOF - set -e - ulimit -c unlimited - ${{ matrix.test }} - EOF + # FIXME: As long as we use per-run ccache caches, we should probably add + # a step that checks if there is sufficient new content to warrant + # saving the new cache. + - &ccache_save_step + name: Save ccache + uses: actions/cache/save@v5 + with: + path: ${{ env.CCACHE_DIR }} + key: ${{ steps.ccache_restore.outputs.cache-primary-key }} - - name: Core backtraces - if: failure() + # Run a minimal set of tests. The main regression tests take too long + # for this purpose. For now this is a random quick pg_regress style + # test, and a tap test that exercises both a frontend binary and the + # backend. + # + # To allow the command below to be reused by later tasks, we allow + # adding "setup" commands to be specified via the ADDITIONAL_SETUP + # environment variable. + # + # Note that this command is used on all platforms, therefore one needs + # to be careful about using only ${{env.}} variable references, + # linebreaks etc. + - name: Test + shell: *su_postgres_shell + env: + MTEST_TARGET: cube/regress pg_ctl/001_start_stop + run: &meson_test_world_cmd | + ${{case(runner.os == 'Windows', '', 'ulimit -c unlimited')}} + + ${{env.ADDITIONAL_SETUP}} + + echo ::group::test_setup + meson test ${{env.MTEST_ARGS}} --suite setup --logbase setup + echo ::endgroup:: + + meson test ${{env.MTEST_ARGS}} --num-processes ${{env.TEST_JOBS}} ${{env.MTEST_TARGET}} + + - &linux_collect_cores + name: Core backtraces + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh linux /tmp/cores - - name: Upload logs - if: failure() + # Note that this is used for both meson and autoconf builds + - &upload_logs_step + name: Upload logs + if: failure() && !cancelled() uses: actions/upload-artifact@v7 with: - name: linux-${{ matrix.slug }}-logs-${{ github.run_id }} - path: ${{ matrix.logs_paths }} + name: logs-${{ github.job }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + **/*.log + **/*.diffs + **/regress_log_* + **/crashlog-*.txt if-no-files-found: ignore + # Linux, Autoconf + # + # SPECIAL: + # - Uses address sanitizer (sanitizer failures are typically printed in + # the server log) + # - Configures postgres with a small segment size + # - Uses PG_TEST_PG_COMBINEBACKUP_MODE=--copy-file-range + linux-autoconf: + name: Linux - Autoconf + needs: [setup, sanity-check] + if: &linux_job_if | + !cancelled() && + needs.setup.outputs.linux == 'true' && + needs.sanity-check.result != 'failure' + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + + env: &linux_env + # Add both debian and linux, as symbols from the host can be visible during profiling + DEBUGINFOD_URLS: "https://debuginfod.debian.net https://debuginfod.ubuntu.com"; + # Use -O2 to reduce the test times, use -fno-sanitize-recover=all to make sanitizer test + # failures visible. + CFLAGS: -O2 -ggdb -fno-sanitize-recover=all + CXXFLAGS: -O2 -ggdb -fno-sanitize-recover=all + LDFLAGS: + CC: ccache gcc + CXX: ccache g++ + CLANG: ccache clang + + # Configure sanitizer runtime behavior to be suitable for running tests: + # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes + # print_stacktraces=1,verbosity=2, duh + # detect_leaks=0: too many uninteresting leak errors in short-lived binaries + UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2 + ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0 + + steps: + # GitHub Actions does not make it easy to share some, but not all, + # environment variables between related tasks. We solve that for the + # linux- tasks by updating the environment variables programmatically. + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=address + PG_TEST_PG_COMBINEBACKUP_MODE: --copy-file-range + run: &linux_update_config_cmd | + echo "CFLAGS=$CFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "CXXFLAGS=$CXXFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + echo "LDFLAGS=$LDFLAGS ${SANITIZER_FLAGS}" >> "$GITHUB_ENV" + + echo "CC=${CC}" >> "$GITHUB_ENV" + echo "CXX=${CXX}" >> "$GITHUB_ENV" + + echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV" + echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV" + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + ./configure \ + --enable-cassert --enable-injection-points --enable-debug \ + --enable-tap-tests --enable-nls \ + --with-segsize-blocks=6 \ + --with-libnuma \ + --with-liburing \ + ${LINUX_CONFIGURE_FEATURES} + + - name: Build + shell: *su_postgres_shell + run: | + make -s -j${BUILD_JOBS} world-bin + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: | + make -s ${CHECK} ${CHECKFLAGS} -j${TEST_JOBS} + + - *linux_collect_cores + - *upload_logs_step + + + # Linux Meson, 32 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + # - tests with LANG=C to give ICU some buildfarm-uncovered coverage. Also, + # newer Python insists on changing LC_CTYPE away from C, prevent that with + # PYTHONCOERCECLOCALE. + linux-meson-32: + name: Linux - Meson (32-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + CC: ccache gcc -m32 + CXX: ccache g++ -m32 + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \ + -DPERL=perl5.40-i386-linux-gnu \ + -Dlibnuma=disabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + env: + PYTHONCOERCECLOCALE: 0 + LANG: C + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # Linux Meson, 64 bit + # + # SPECIAL: + # - Uses undefined behaviour and alignment sanitizers, (sanitizer failures + # are typically printed in the server log) + # - Uses io_method=io_uring + # - Uses meson feature autodetection + linux-meson-64: + name: Linux - Meson (64-bit) + needs: [setup, sanity-check] + if: *linux_job_if + runs-on: ubuntu-latest + container: *linux_ci_container + timeout-minutes: 60 + env: *linux_env + + steps: + - name: Update Environment + env: + SANITIZER_FLAGS: -fsanitize=alignment,undefined + PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring + run: *linux_update_config_cmd + + - *nix_sysinfo_step + - *checkout_step + - *ccache_restore_step + - *linux_prepare_workspace + + - name: Configure + shell: *su_postgres_shell + run: | + meson setup \ + ${MESON_COMMON_PG_CONFIG_ARGS} \ + -Duuid=e2fs \ + --buildtype=debug \ + -Dllvm=enabled \ + build + + - name: Build + shell: *su_postgres_shell + run: *ninja_build_command + + - *ccache_save_step + + - name: Test world + shell: *su_postgres_shell + run: *meson_test_world_cmd + + - *linux_collect_cores + - *upload_logs_step + + # SPECIAL: # - Enables --clone for pg_upgrade and pg_combinebackup # - Specifies configuration options that test reading/writing/copying of node trees @@ -449,13 +529,6 @@ jobs: runs-on: macos-15 timeout-minutes: 60 env: - BUILD_JOBS: 4 - # Test performance regresses noticeably when using all cores. 8 works OK. - # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de - # Fix: Needs to be re-tested for GitHub Actions. - TEST_JOBS: 8 - - CCACHE_DIR: ${{ github.workspace }}/ccache_dir MACPORTS_CACHE: ${{ github.workspace }}/macports-cache MESON_FEATURES: >- @@ -497,44 +570,28 @@ jobs: -c debug_parallel_query=regress steps: - - *checkout_step + - *nix_sysinfo_step - - name: Sysinfo - run: | - id - uname -a - ulimit -a -H && ulimit -a -S - env + - *checkout_step - name: Setup core files run: | mkdir -p $HOME/cores sudo sysctl kern.corefile="$HOME/cores/core.%P" - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-macos-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-macos-${{ github.ref_name }}- - ccache-macos- - - - name: Compute MacPorts cache key + - name: "Macports: Compute cache key" id: mpkey run: | macos_major=$(sw_vers -productVersion | sed 's/\..*//') pkglist_hash=$(printf '%s' "$MACOS_PACKAGE_LIST" | md5 -q) script_hash=$(md5 -q src/tools/ci/ci_macports_packages.sh) - echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" - echo "restore-key=macports-${macos_major}-${pkglist_hash}-${script_hash}-" >> "$GITHUB_OUTPUT" + echo "key=macports-${macos_major}-${pkglist_hash}-${script_hash}" >> "$GITHUB_OUTPUT" - - name: Restore MacPorts cache + - name: "MacPorts: Restore cache" uses: actions/cache@v5 with: path: ${{ env.MACPORTS_CACHE }} key: ${{ steps.mpkey.outputs.key }} - restore-keys: ${{ steps.mpkey.outputs.restore-key }} # Use MacPorts, even though Homebrew is installed. The installation # of the additional packages we need would take quite a while with @@ -546,7 +603,7 @@ jobs: # the large MacPort tree around to figure out that p5-io-tty is # actually p5.34-io-tty. Using the unversioned name works, but # updates MacPorts every time. - - name: Install dependencies (MacPorts) + - name: "MacPorts: Install dependencies" env: # Pass token so the script's GitHub API call to list MacPorts # releases isn't subject to the 60/h/IP unauthenticated rate @@ -560,11 +617,14 @@ jobs: echo /opt/local/sbin >> "$GITHUB_PATH" echo /opt/local/bin >> "$GITHUB_PATH" + - *ccache_restore_step + - name: Configure + env: + PKG_CONFIG_PATH: /opt/local/lib/pkgconfig/ run: | - export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/" meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ --buildtype=debug \ -Dextra_include_dirs=/opt/local/include \ -Dextra_lib_dirs=/opt/local/lib \ @@ -574,25 +634,21 @@ jobs: build - name: Build - run: ninja -C build -j${BUILD_JOBS} ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: | - ulimit -c unlimited # default is 0 - ulimit -n 1024 # default is 256, pretty low - meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + env: + # default is 256, pretty low + ADDITIONAL_SETUP: ulimit -n 1024 + run: *meson_test_world_cmd - name: Core backtraces - if: failure() + if: failure() && !cancelled() run: src/tools/ci/cores_backtrace.sh macos "$HOME/cores" - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: macos-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-vs: @@ -605,10 +661,10 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 8 # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' + TAR: "c:/windows/system32/tar.exe" MESON_FEATURES: >- -Dcpp_args=/std:c++20 @@ -618,13 +674,13 @@ jobs: -Dssl=openssl -Dplperl=enabled -Dplpython=enabled - TAR: "c:/windows/system32/tar.exe" defaults: run: shell: cmd steps: - - name: Disable Windows Defender + - &windows_disable_defender + name: Disable Windows Defender shell: powershell run: | Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable @@ -723,33 +779,36 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - name: Configure run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson setup --backend ninja %MESON_COMMON_PG_CONFIG_ARGS% %MESON_FEATURES% --buildtype debug -Db_pch=true -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include -DTAR=%TAR% build + meson setup ^ + --backend ninja ^ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} ^ + ${{env.MESON_FEATURES}} ^ + --buildtype debug ^ + -Db_pch=true ^ + -Dextra_lib_dirs=d:\openssl\1.1\lib -Dextra_include_dirs=d:\openssl\1.1\include ^ + -DTAR=${{env.TAR}} ^ + build - name: Build run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - ninja -C build %MBUILD_TARGET% + ninja -C build ${{env.MBUILD_TARGET}} ninja -C build -t missingdeps - name: Test world - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - meson test %MTEST_ARGS% --num-processes %TEST_JOBS% + env: + ADDITIONAL_SETUP: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-vs-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step windows-mingw: @@ -762,7 +821,7 @@ jobs: runs-on: windows-2022 timeout-minutes: 60 env: - TEST_JOBS: 4 # higher concurrency causes occasional failures + # Avoid port conflicts between concurrent tap tests PG_TEST_USE_UNIX_SOCKETS: 1 PG_REGRESS_SOCK_DIR: 'd:\pgsock' TAR: "c:/windows/system32/tar.exe" @@ -776,7 +835,6 @@ jobs: MESON_FEATURES: >- -Dnls=disabled - CCACHE_DIR: D:/a/ccache CCACHE_MAXSIZE: "500M" CCACHE_SLOPPINESS: pch_defines,time_macros CCACHE_DEPEND: 1 @@ -786,17 +844,7 @@ jobs: shell: 'D:\msys64\usr\bin\bash.exe --login -eo pipefail "{0}"' steps: - - name: Disable Windows Defender - shell: powershell - run: | - Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disable - # Verify Defender status - $status = Get-MpComputerStatus -ErrorAction SilentlyContinue - if ($status) { - Write-Host "RealTimeProtectionEnabled: $($status.RealTimeProtectionEnabled)" - Write-Host "AntivirusEnabled: $($status.AntivirusEnabled)" - } - + - *windows_disable_defender - *checkout_step # Relocate the preinstalled MSYS2 tree from C:\ (slow system disk) to @@ -835,6 +883,8 @@ jobs: ${MINGW_PACKAGE_PREFIX}-readline \ ${MINGW_PACKAGE_PREFIX}-zlib + - *nix_sysinfo_step + - name: Install additional dependencies run: | # Pin IPC::Run to NJM/IPC-Run-20250809.0; TODDR/IPC-Run-20260322.0 @@ -845,42 +895,32 @@ jobs: - name: Setup socket directory shell: cmd - run: mkdir %PG_REGRESS_SOCK_DIR% + run: mkdir ${{env.PG_REGRESS_SOCK_DIR}} - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-mingw-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-mingw-${{ github.ref_name }}- - ccache-mingw- + - *ccache_restore_step - name: Configure run: | meson setup \ - ${MESON_COMMON_PG_CONFIG_ARGS} \ + ${{env.MESON_COMMON_PG_CONFIG_ARGS}} \ -Ddebug=true -Doptimization=g -Db_pch=true \ - ${MESON_COMMON_FEATURES} \ - ${MESON_FEATURES} \ - -DTAR=${TAR} \ + ${{env.MESON_COMMON_FEATURES}} \ + ${{env.MESON_FEATURES}} \ + -DTAR=${{env.TAR}} \ build - name: Build - run: ninja -C build ${MBUILD_TARGET} + run: *ninja_build_command + + - *ccache_save_step - name: Test world - run: meson test ${MTEST_ARGS} --num-processes ${TEST_JOBS} + run: *meson_test_world_cmd # FIX: We need to collect crashlogs but they are not collected. cdb.exe # is installed on the runner so it needs to be configured. - - name: Upload logs - if: failure() - uses: actions/upload-artifact@v7 - with: - name: windows-mingw-logs-${{ github.run_id }} - path: *log_paths - if-no-files-found: ignore + - *upload_logs_step + # Test that code can be built with both gcc and clang without warnings, # with various combinations of cassert/dtrace flags. Trace probes have @@ -900,24 +940,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 container: - image: ${{ needs.setup.outputs.linux_ci_image }} + image: ${{ needs.setup.outputs.container_linux_ci_docs }} env: - BUILD_JOBS: 4 - CCACHE_DIR: /tmp/ccache_dir # Use larger ccache cache as this job compiles with multiple # compilers / flag combinations. CCACHE_MAXSIZE: "1G" steps: - - *checkout_step - - - name: Restore ccache - uses: actions/cache@v5 - with: - path: ${{ env.CCACHE_DIR }} - key: ccache-compiler-warnings-${{ github.ref_name }}-${{ github.run_id }} - restore-keys: | - ccache-compiler-warnings-${{ github.ref_name }}- - ccache-compiler-warnings- - name: Sysinfo run: | @@ -929,83 +957,108 @@ jobs: clang -v env + - *checkout_step + + - *ccache_restore_step + - name: Setup workspace run: | echo "COPT=-Werror" > src/Makefile.custom - mkdir -p "$CCACHE_DIR" # gcc, cassert off, dtrace on - name: gcc warnings + (dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # gcc, cassert on, dtrace off - name: gcc warnings + (cassert) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ --enable-cassert \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin # clang, cassert off, dtrace off - name: clang warnings - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + # clang, cassert on, dtrace on - name: clang warnings + (cassert + dtrace) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache clang.cache \ --enable-cassert \ --enable-dtrace \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + - name: mingw warnings (cross compilation) - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --host=x86_64-w64-mingw32ucrt \ --enable-cassert \ --without-icu \ CC="ccache x86_64-w64-mingw32ucrt-gcc" \ CXX="ccache x86_64-w64-mingw32ucrt-g++" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} world-bin + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} world-bin + ### # Verify docs can be built ### # XXX: Only do this if there have been changes in doc/ since last build - name: Build documentation - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ --cache gcc.cache \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -C doc + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -C doc ### # Verify headerscheck / cpluspluscheck succeed @@ -1015,12 +1068,19 @@ jobs: # - Use -fmax-errors, as particularly cpluspluscheck can be very verbose ### - name: headerscheck + cpluspluscheck - if: always() + if: ${{ !cancelled() }} run: | + echo "::group::configure" ./configure \ - ${LINUX_CONFIGURE_FEATURES} \ + ${{env.LINUX_CONFIGURE_FEATURES}} \ --cache gcc.cache \ --quiet \ CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang" - make -s -j${BUILD_JOBS} clean - make -s -j${BUILD_JOBS} -k ${CHECKFLAGS} headerscheck cpluspluscheck EXTRAFLAGS='-fmax-errors=10' + echo "::endgroup::" + + make -s -j${{env.BUILD_JOBS}} clean + make -s -j${{env.BUILD_JOBS}} -k ${{env.CHECKFLAGS}} \ + headerscheck cpluspluscheck \ + EXTRAFLAGS='-fmax-errors=10' + + - *ccache_save_step -- 2.54.0.380.gc69baaf57b --rv3g7aw7ud36z5b5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v6a-0003-disable-cirrus.patch" ^ permalink raw reply [nested|flat] 249+ messages in thread
end of thread, other threads:[~2026-06-01 19:09 UTC | newest] Thread overview: 249+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-03-29 15:43 [PATCH v15] Avoid orphaned objects dependencies Bertrand Drouvot <bertranddrouvot.pg@gmail.com> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de> 2026-06-01 19:09 [PATCH v6a 2/5] gha: Andres' revisions Andres Freund <andres@anarazel.de>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox